Window.closed (Property)

A property value that is true if the window is closed.

Availability:

JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Opera - 3.0
Property/method value type:Boolean primitive
JavaScript syntax:-closed
-myWindow.closed

From JavaScript version 1.1 onwards, a window object may persist after it has been closed. This may seem odd but it is possible that the window object will have had other object references added to it and for it to be deleted, it must relinquish those references. Without this object persistence, a dangerous cascading delete effect may happen, inadvertently discarding all manner of objects within your script context.

The only valid thing you should access at this point is the closed property. This allows you to check for the window having been closed by the user before you try to do something with it.

Some programmers would argue that this is poor technique anyway and that a reference to a window held externally should be nulled by the closing function. That way you can test a variable that exists within the script's scope chain rather than an object that should probably have been purged from memory. Given the bugs in the implementation of this feature, that is a better way to determine whether a window is still in existence.

Warnings:

See also:Frame object, Window object

Property attributes:

ReadOnly.