asp.net.ph

Skip Navigation Links

closed Property

window Properties   Object Properties Summary


Retrieves whether the referenced window is closed.

Syntax


HTML N/A
Script [ bClosed = ] window.closed

Possible Values


false The window is open.
true The window is closed.

The property is read-only with a default value of false.

Example

This example opens a named window and shows use of the closed property to check if the window object is closed.

<div align="center"><form>
<input type="button" value="Open window"
  onclick="openWin ( )">
<input type="button" value="Check if closed"
  onclick="chkIfClosed ( )"></form></div>

<script language="JavaScript">
<!--
function openWin ( ) {
theWin=window.open ( "../sample.html", "theWin",
  "height=300,width=500" )
}

function chkIfClosed ( ) {
if ( typeof ( theWin ) =="object" ) {
  msg="The window.closed property returns "+
    theWin.closed;
  if ( theWin.closed ) {
    alert ( "As the other window is already closed,
      \n the window.closed property returns "+
      theWin.closed );
       theWin = null;}   
  else
    alert ( "As the other window is still open,
    \n the window.closed property returns "+
    theWin.closed );
  }
else
  alert ( "Nothing to do. 
    Please open the window first." )
}
//-->
</script>
Applies To

window

See Also

close Method, open Method, opener Property



>

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note