Javascript window.open在Win7 x64上的32位IE8中返回null [英] Javascript window.open returns null in 32-bit IE8 on Win7 x64

查看:447
本文介绍了Javascript window.open在Win7 x64上的32位IE8中返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have read the related questions on this topic, but haven't yet found a solution to this issue. I have a simple javascript function that calls window.open when a link is clicked:

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或不是对象

This works fine on Chrome, Firefox, and even works in 64-bit IE 8. However, when I try this in 32-bit IE 8 I get an error that 'newwindow' is null or not an object.

为什么会出现这种情况只能在32位IE 8中出现?

Any ideas on why this would occur only in 32-bit IE 8?

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

My hunch was that it was related to UAC in Windows 7 (I am running Win 7 x64), but I get the error even after turning Protected Mode off and running with Compatibility View on.

我也想知道为什么Windows 7 x64同时配备32位和64位版本的IE 8,以及为什么32位版本固定在我的任务栏上...

I also wonder why Windows 7 x64 comes with both the 32-bit and 64-bit versions of IE 8, and why the 32-bit version was pinned to my taskbar...

推荐答案

如果网址超出当前域,则Internet Explorer似乎返回null。你可以先打开一个空页来解决它,然后在窗口中导航到实际网址:

Internet Explorer seems to return null if the url is outside your current domain. You can work around it by open an empty page first, then navigate the window to the actual url:

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

    if (window.focus) {newwindow.focus();}
}

这篇关于Javascript window.open在Win7 x64上的32位IE8中返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆