0

Is thee a way for Determining wheter a window by window.open() is closed or not in javascript? Following is a simple code for opening a window.

<script type="text/javascript">
var win = window.open("test.htm")
</script>

When some event is fired. a event handler should determine a window is still opened.

if ( /* is a window alive */ )
    alert("window is still alive!");
else
    alert("window was closed!");
sweetier
  • 131
  • 1
  • 3
  • 11

2 Answers2

2

Check the Window.closed property.

This property indicates whether the referenced window is closed or not. [Read only].

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

The code provided for this question seem to be more complete than simply checking for closed: JavaScript window.open only if the window does not already exist

Community
  • 1
  • 1
E. Jaep
  • 2,095
  • 1
  • 30
  • 56