gpt4 book ai didi

javascript - setTimeout 在 IE11 上无法按预期工作

转载 作者:行者123 更新时间:2023-12-03 03:58:42 27 4
gpt4 key购买 nike

我有以下网页:

<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>

当我使用 Chrome 或 Firefox 打开它时,我在关闭弹出窗口后看到“已关闭”消息。然而在 IE11 中什么也没有发生。这种行为差异的解释是什么? (即 IE11 不遵守标准的哪一部分,或者在这种情况下有不同的解释?)

编辑:阅读建议的答案,我尝试更改 setTimeout(wait,1000,popup)setTimeout(function() {wait(popup);},1000) ,像这样:

<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>

但这也不起作用。

编辑:评论表明这是重复的,但由于尝试根据建议的答案更改代码直到现在对我来说都不起作用,因此我通过要求更改来修改问题上面的代码,以便它可以在 IE11 中工作(希望 SO 规则允许这样做)。显示的代码不起作用。

最佳答案

这个有点困扰我,所以我在本地文件上尝试了它并得到了相同的行为。 window.open 在 IE 和 Edge 中都返回 null。显然,如果启用了保护模式,window.open 在 IE 和 Edge 中都会返回 null。

https://msdn.microsoft.com/en-us/library/Bb250462.aspx

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

关于javascript - setTimeout 在 IE11 上无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44827653/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com