【问题标题】:multiple javascript window.open calls fail in chrome and IE11多个 javascript window.open 调用在 chrome 和 IE11 中失败
【发布时间】:2014-09-08 19:28:31
【问题描述】:

一组多个 window.open() 调用,如http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open6 所述,例如...

    w1=window.open("http://www.google.com/");
    w2=window.open("http://www.w3schools.com/");

...在 FireFox 中按预期工作,但在 Chrome 36 和 IE 11 中仅打开一个新标签。

有人知道如何在 Chrome 和 IE 中完成这项工作吗?

【问题讨论】:

  • 您的第二个弹出窗口被内置的弹出窗口阻止程序阻止。为什么需要同时打开多个弹窗?
  • 我自己也遇到了同样的问题。我不认为“为什么”特别重要,我需要一个按钮在新选项卡或窗口中打开两个页面。在 Chrome 中连续进行两次window.open() 调用只会打开第一个并阻止第二个。在其他浏览器中运行良好。

标签: javascript internet-explorer google-chrome window.open


【解决方案1】:

我在尝试弹出两个独立窗口时遇到了同样的问题。第二个窗口将替换第一个窗口的链接。我发现答案是给窗口起不同的名字。示例:“test1”和“test2”

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-01-31
  • 2017-10-26
  • 2012-03-18
  • 2019-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多