A function to check if a window is closed:
function checkWin() {
if (!myWindow) {
text = "It has never been opened!";
} else {
if (myWindow.closed) {
text = "It is closed.";
} else {
text = "It is open.";
}
}
}
Try it Yourself »
The closed
property returns true
if the window is closed.
The closed
property is read-only.
window.closed
Type | Description |
A boolean | true if the window is closed, otherwise false . |
window.closed
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!