title: How do I check that opened window is closed with javascript?
body: <p>is there any way to detect that which popup window i have opened is closed or not?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  // global variable for subwindow reference
  var newWindow;
  // generate and fill the new window
  function makeNewWindow() {
      // make sure it isn't already opened
          newWindow = window.open("http://www.google.com","sub","status,height=200,width=300");
  
  }
  
  function checkWindow() {
      if(newWindow.closed){
          document.write("Window has closed.");
      }
  }
  &lt;/script&gt;
      &lt;form&gt;
  &lt;input type="button" value="Create New Window" onclick="makeNewWindow();" /&gt;
  &lt;script&gt;
      checkWindow();
  &lt;/script&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I want that when i close the opened window. the function checkWindow() print on screen that "Window has closed." Please suggest me some helping code. thanks in advance</p>