Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Window closed property

Window closed property

Window Object Reference Window Object


Definition and Usage

The closed property returns a Boolean value that declares whether the window has been closed.

Syntax

window.closed


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the closed property


Example

Example

Check 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 »


Window Object Reference Window Object