Window closed property

Definition and usage

If the window is closed, then closed The property returns true.

closed The property is read-only.

See also:

open() method

close() method

Example

Function to check if the 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

Syntax

window.closed

Return value

Type Description
Boolean Value If the window is closed, it is true; otherwise, it is false.

Browser Support

All Browsers Support window.closed:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support