javascript 在 IE 11 + Windows 8.1 预览版上调用 window.open() 返回 null
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18503880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
call to window.open() returns null on IE 11 + Windows 8.1 Preview
提问by Chris_vr
I am doing somethig like this,where MyConfig is a aspx page.
我正在做这样的事情,其中 MyConfig 是一个 aspx 页面。
winOpen=window.open('/Account/Register','MyConfig','toolbar=no,status=no,location=no,menubar=0,resizable=yes,scrollbars=yes,width=' + wWidth + ',height='+ wHeight + ',top=' + wTop + ',left=' +wLeft);
winOpen.focus();
winOpen.focus();
It returns null.It is working fine in chrome + WIndows 8.1 preview,But it is not working in IE 11.
它返回 null。它在 chrome + WINdows 8.1 预览版中工作正常,但在 IE 11 中不起作用。
EDIT
编辑
I have added one more line in the question and actually that line is failing since window.open() return null and so is winOpen.focus().I turned to compatibility mode and than launched the page now it is giving me the same WebPage error but I am able to navigate to the page.I wanted it to work in without compatibility mode setting.user might not know the setting.
我在问题中又添加了一行,实际上该行失败了,因为 window.open() 返回 null,winOpen.focus() 也是如此。我转向兼容模式,然后启动页面,现在它给了我相同的网页错误,但我能够导航到该页面。我希望它在没有兼容模式设置的情况下工作。用户可能不知道该设置。
回答by Khodor
uncheck "Enable Protected Mode" in internet options
在 Internet 选项中取消选中“启用保护模式”
回答by Daniel Eduardo Delgado Diaz
Same problem with IE 11 on windows 10
Windows 10 上的 IE 11 也有同样的问题
At difference than @Khodor workaround, I get the expected behavior doing this:
与@Khodor 解决方法不同的是,我得到了预期的行为:
- Open internet options popup.
- Select security tab.
- Check 'Enable Protected Mode'.
- Close and Open IE again.
- 打开 Internet 选项弹出窗口。
- 选择安全选项卡。
- 选中“启用保护模式”。
- 关闭并再次打开 IE。
I thougt that the null was caused for 'not found' response, ssl, different domain, etc. I tested and dicarded all of them.
我认为 null 是由“未找到”响应、ssl、不同域等引起的。我测试并放弃了所有这些。
回答by Hanlet Esca?o
Your first argument is supposed to be a string, and you are missing a plus sign by wHeight
:
你的第一个参数应该是一个字符串,你缺少一个加号wHeight
:
winOpen=window.open('/Account/Register','MyConfig','toolbar=no,status=no,location=no,menubar=0,resizable=yes,scrollbars=yes,width=' + wWidth + ',height=' + wHeight + ',top=' + wTop + ',left=' +wLeft);
Edit: Check and make sure your IE allows popups on the site you are using to test. If it does not, and the popup does not open, it will return null. Allowing popups will fix the problem.
编辑:检查并确保您的 IE 允许在您用于测试的站点上弹出窗口。如果没有,并且弹出窗口没有打开,它将返回 null。允许弹出窗口将解决问题。