0

从主窗口我尝试用 javascript 打开一个弹出窗口,做一些工作并关闭弹出窗口。仅在 chrome 中,此弹出窗口在所有工作完成之前为空,因此它不显示任何内容并关闭。如果我不关闭它,我可以看到它需要一段时间才能加载然后显示内容。在 IE 和 Firefox 中,内容会立即显示。有谁知道是否有解决方法或解决方法?

这是我的代码:

<html>
    <body>
        <script>
            function launch() {
                var pop = window.open ("http://google.com", "pop", "width=300,height=150");
                for (i = 0; i < 1000000000; i++) {
                    var a = i; //Do anything just to make it stay for a while
                }
                pop.close();
            }
        </script>
        <input onclick="launch();" type="button" value="Hello world!">
    </body>
</html>
4

1 回答 1

0

你可以试试这个:

function func1() {
  var p=window.open ("http://google.com", "pop", "width=300,height=150");
  setTimeout (function(){p.close()},5000);
 }

该窗口将显示 5 秒钟。

于 2013-11-08T17:33:07.417 回答