繁体   English   中英

为什么这个window.open可以在Chrome和FF上运行但不能在IE上运行?

[英]Why does this window.open work on Chrome and FF but not IE?

下面的javascript / html在用户屏幕的右下方创建了一个小的弹出窗口。 出于某些原因,此代码在Chrome和Firefox上有效,但在IE v9上无效。

在IE9调试器中,它说“行:17错误:参数无效”。

第17行是以var win = window.open(...

在调试器中,我看到:

HTML1202: http://xyzserver:8080/path/test_popup.html is running in Compatibility View because 'Display intranet sites in Compatibility View' is checked. 

脚本87:无效的参数。 test_popup.html,第17行字符3

字符是var win中的v = ...

有任何想法吗?

<!DOCTYPE html>
<html>
<head>
<script>
function open_win(data) 
{
  var w = 200;
  var h = 200;
  var left = (screen.width - (w * 1.1)); 
  var top  = (screen.height - (h * 1.1));

  var win = window.open('', 'about:blank', 'width=' + w + ',  height=' + h + ', top=' + top + ', left=' + left);
  win.document.write("<p>Received: " + data + "</p>")
  win.focus()
}
</script>
</head>

<body>
<form>
<input type="button" value="Open Window" onclick="open_win('information here')">
</form>
</body>

</html>

需要传递about:blank作为第一个参数,而不是第二个(这是窗口名称,显然可以不包含。 :在IE)

尝试这个:

var win = window.open('', '', 'width=' + w + ',  height=' + h + ', top=' + top + ', left=' + left);

因此没有'about:blank'因为Microsoft不支持将名称用作第二个参数。

或者您应该说: window.open('_blank', '', 'width='...)....etc以名称作为第一个参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM