JavaScript HTML DOM Window closed 属性
-
Window closed 属性
closed属性返回一个布尔值,指示窗口是否已关闭。检查名为“myWindow”的窗口是否已关闭的函数:
尝试一下function checkWin() { if (!myWindow) { document.getElementById("msg").innerHTML = "'myWindow' has never been opened!"; } else { if (myWindow.closed) { document.getElementById("msg").innerHTML = "'myWindow' has been closed!"; } else { document.getElementById("msg").innerHTML = "'myWindow' has not been closed!"; } } }
-
浏览器支持
项 IE/Edge Chrome FireFox Safari Opera 属性 closed 支持支持支持支持支持 -
语法
返回closed属性:window.closed -
技术细节
项目 描述 返回值: 一个布尔值,如果窗口已关闭,则为true;如果窗口打开,则为false