【问题标题】:IE11 on WIN 8.1 : window.open with the same name is opening new popup windowWIN 8.1 上的 IE11:window.open 同名正在打开新的弹出窗口
【发布时间】:2013-08-24 17:52:59
【问题描述】:

当运行下面的 HTML 页面时,它会打开两个弹出窗口。以前版本的 IE 并非如此。当使用已打开的相同窗口名称进行 window.open 调用时,它应该返回对已打开窗口的引用。但在 IE11 中它正在打开另一个新窗口。

<html>
<head>
<script type="text/javascript">
window.open("http://www.google.com", "test", "resizable=no,scrollbars=yes,width=260,height=225");
window.open("http://www.google.com", "test", "resizable=no,scrollbars=yes,width=260,height=225");
</script>
</head>
</html>

如果您未提及 url,则不会发生此行为。 (见下面的html页面)。下面的html页面只启动一个弹出窗口。

<html>
<head>
<script type="text/javascript">
window.open("", "test", "resizable=no,scrollbars=yes,width=260,height=225");
window.open("", "test", "resizable=no,scrollbars=yes,width=260,height=225");
</script>
</head>
</html>

当我们提供 url 或导航到 url 窗口时,它会失去它的名字。如果您尝试使用 window.name 获取弹出窗口名称,则会返回空字符串。

仅在 Windows 8.1 和 IE 11 中发生,在 Windows 7 和 IE11 中不发生。 我需要做任何调整才能在 IE11 中进行这项工作吗?

更新: 这似乎是 IE 错误。 IE 团队正在对此进行调查。 https://connect.microsoft.com/IE/feedback/details/797964/ie11-win-8-1-window-open-with-the-same-name-is-opening-new-popup-window#details

更新 2: 仅当 Internet Explorer 在提升模式下运行时才会发生。

【问题讨论】:

  • 查看设置。也许有人说“总是在新标签中打开新窗口”
  • 嗨 mplungjan,如果我选择该设置,则 window.open 调用在新选项卡中打开它,但我希望它在新窗口中打开。
  • 我的意思是:取消选中,如果它被选中
  • 您在更新中引用的“CONNECT”错误意味着您正在穿越 URLMon 安全区域,因此您丢失了对窗口的引用。如果原始页面和弹出窗口位于同一安全区域,您的代码应该可以工作。
  • @EricLaw,其他浏览器没有这个问题。为什么 IE 总是做一些不同的事情???

标签: javascript window.open windows-8.1 internet-explorer-11


【解决方案1】:

请试试这个..这将检查窗口是否仍然打开或关闭..

<script type="text/javascript">
 var myWindow = null;

 if(!myWindow || (myWindow && myWindow.closed)){
 myWindow = window.open("http://www.google.com", "test", "resizable=no,scrollbars=yes,width=260,height=225");
          }
         else{
       myWindow.location.href = 'http://www.google.com';
       }

</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-06
    • 1970-01-01
    相关资源
    最近更新 更多