Window closed

Example

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 »

Description

The closed property returns true if the window is closed.

The closed property is read-only.


Syntax

window.closed

Return Value

Type Description
A booleantrue if the window is closed, otherwise false.

Browser Support

window.closed is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.