Javascript window.open 在 Win7 x64 上的 32 位 IE8 中返回 null

2023-11-21

我已阅读有关此主题的相关问题,但尚未找到此问题的解决方案。我有一个简单的 javascript 函数,在单击链接时调用 window.open:

var newwindow;
function pop(url)
{
    newwindow=window.open(url,'','height=500,width=532');
    if (window.focus) {newwindow.focus();}
}

这在 Chrome、Firefox 上运行良好,甚至在 64 位 IE 8 中也能运行。但是,当我在 32 位 IE 8 中尝试此操作时,出现错误:'newwindow' 为 null 或不是对象.

关于为什么这种情况仅在 32 位 IE 8 中发生的任何想法?

我的预感是它与 Windows 7 中的 UAC 有关(我运行的是 Win 7 x64),但即使在关闭保护模式并在兼容性视图下运行后我也会收到错误。

我还想知道为什么 Windows 7 x64 附带 32 位和 64 位版本的 IE 8,以及为什么 32 位版本固定在我的任务栏上......


如果 url 位于当前域之外,则 Internet Explorer 似乎会返回 null。您可以通过先打开一个空页面,然后将窗口导航到实际的 url 来解决此问题:

var newwindow;
function pop(url)
{
    newwindow=window.open('','','height=500,width=532');
    newwindow.location = url;

    if (window.focus) {newwindow.focus();}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Javascript window.open 在 Win7 x64 上的 32 位 IE8 中返回 null 的相关文章

随机推荐