gpt4 book ai didi

javascript - javascript中通过window.open()判断窗口是否关闭

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

在 JavaScript 中是否可以通过 window.open() 确定窗口是否关闭?以下是打开窗口的简单代码。

<script type="text/javascript">
var win = window.open("test.htm")
</script>

当某个事件被触发时。事件处理程序应该确定窗口仍然打开。

if ( /* is a window alive */ )
alert("window is still alive!");
else
alert("window was closed!");

最佳答案

检查Window.closed property .

This property indicates whether the referenced window is closed or not. [Read only].

关于javascript - javascript中通过window.open()判断窗口是否关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4551190/

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