title: In Javascript how to find if a window is open or closed
body: <p>Below is the code which I am using in my HTML page. My requirement is,..</p>
  
  <p>1) User when clicks on a a 'Open' button a new window with content should open. Now when user navaigates to someother page and comes back and clicks on the same 'Open' button then no new window should open as it is already open. </p>
  
  <p>2) But if I close the opened window and then hit 'Open' button then new window should open. </p>
  
  <p>I could achieve the first requirement with below code but not able to achieve the 2nd requirement with below code. I always get window.closed as false. Please help.</p>
  
  <pre><code>&lt;script&gt;
  
  var win1;
  
  // The if condition is for achieveing 1st requirement which is perfect
  
  if(window.sessionStorage.getItem('isOpenOnce') == null)
  {
  window.sessionStorage.setItem('isOpenOnce', 'opened');
  win1 = window.open("http://www.example.com");
  
  }
  
  // the below else if is for achieveing 2nd requirement which is failing.
  
  else if(win1.closed)
  {
  win1.location.reload();
  }
  
  else {  
  }
  
  &lt;/script&gt;
  </code></pre>