Window closedProperty

Window 对象参考手册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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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!";
        }
    }    
}

Try it Yourself »


Window 对象参考手册Window Object Other Extensions