Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript setTimeout在IE11上无法按预期工作_Javascript_Internet Explorer_Asynchronous - Fatal编程技术网

Javascript setTimeout在IE11上无法按预期工作

Javascript setTimeout在IE11上无法按预期工作,javascript,internet-explorer,asynchronous,Javascript,Internet Explorer,Asynchronous,我有以下网页: <html> <head> </head> <body> <h1>Wait until closed</h1> <script> function wait(popup){ if (!popup.closed){ setTimeout(wait,1000,popup); } else { alert('closed'); }

我有以下网页:

<html>
<head>
</head>
<body>
<h1>Wait until closed</h1>
<script>

function wait(popup){
      if (!popup.closed){
        setTimeout(wait,1000,popup);
      } else {
        alert('closed');
      } 
    }

var popup = window.open("http://www.google.com", '', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes, width=1000 , height=800, top=' + screen.top + ', left=' + screen.left);

wait(popup); 

</script>
</body>
</html>
但这也不起作用


编辑:注释表明这是重复的,但由于根据建议的答案尝试更改代码直到现在对我不起作用,我修改了问题,要求更改上述代码,使其在IE11中工作(希望so规则允许这样做)。显示的代码不起作用。

这段代码让我有点烦,所以我在本地文件中尝试了它,得到了相同的行为。window.open在IE和Edge中都返回null。显然,如果启用了保护模式,window.open将在IE和Edge中返回null


我不知道如何解决这个问题。可能是一个可关闭的框架?

我很困惑,现在这个问题已经解决了吗?@Huangism不,我试着按照建议去做,但现在这些建议对我不起作用。@user7408846您的编辑部分表明这在IE11中现在起作用了,不是吗?@Huangism我改变了问题的结尾,我希望现在更清楚了。@user7408846我的机器上没有IE11,但我建议你仔细检查一下,看看到底是什么不起作用
<html>
<head>
</head>
<body>
<h1>Wait until closed</h1>
<script>

function wait(popup){
      if (!popup.closed){
        setTimeout( function() {
            wait(popup);
        }, 1000 );
      } else {
        alert('closed');
      } 
    }

var popup = window.open("http://www.google.com", '', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes, width=1000 , height=800, top=' + screen.top + ', left=' + screen.left);

wait(popup); 

</script>
</body>
</html>