title: How to call a function when close popup window
body: <p>I am calling the Javascript <code>window.open()</code> function to load another url in a pop up window.
  When the users closes the popup window, I want the <code>MyThanks()</code> function to be called. How I can do this?</p>
  
  <p>My Script :</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script&gt;
      function openWin(){
          myWindow=window.open('http://facebook.com/ekwebhost','','width=600,height=400,left=200');
          myWindow.focus();
      }
  
      function MyThanks(){
          alert("Thanks");
      }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;input type="button" value="Open window" onclick="openWin()" /&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>Regarding usage of popups:</p>
  
  <p>Are you aware that Facebook &amp; Twitter still use popup windows for user like &amp; follow. Go to <a href="http://www.ekwebhost.com" rel="nofollow">http://www.ekwebhost.com</a> and click the Facebook "Like" button or the Twitter "Follow" button. Why can't I use popup windows for my own needs?</p>