Window closedProperty
Window Object
Definition and Usage
The closed property returns a boolean value that indicates whether the window has been closed.
Syntax
window.closed
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the closed property.
Example
Example
Detect whether the new window "myWindow" has been closed:
function checkWin(){
if (!myWindow){
document.getElementById("msg").innerHTML="My window was not opened!";
}
else{
if (myWindow.closed){
document.getElementById("msg").innerHTML="My window was closed!";
}
else{
document.getElementById("msg").innerHTML="My window was not closed!";
}
}
}
if (!myWindow){
document.getElementById("msg").innerHTML="My window was not opened!";
}
else{
if (myWindow.closed){
document.getElementById("msg").innerHTML="My window was closed!";
}
else{
document.getElementById("msg").innerHTML="My window was not closed!";
}
}
}
Try it Yourself »
Window Object Other Extensions