title: How to detect popup window close event
body: <h3>javascript</h3>
  
  <pre><code>document.querySelector('#share').onclick = function () {
      var popup = window.open('http://www.facebook.com/sharer/sharer.php?u=http://www.google.com', '', "width=400, height=400");
  
      popup.onbeforeunload = function() {
          alert('unload');
      }
  
      return false;
  };
  </code></pre>
  
  <h3>HTML</h3>
  
  <pre><code>&lt;a id="share" href="#"&gt;share&lt;/a&gt;
  </code></pre>
  
  <p>Two things:</p>
  
  <ol>
  <li><p>I want to do something after user finish the facebook share thing, if I share the page by open window the window will be auto close after everything is done, so I want to use <code>beforeload</code> event to imitate <code>after sharing callback</code>, but I can't get it when popup is closed.</p></li>
  <li><p>If user just turn off the window or cancel sharing will also trigger the event, so it's not the best solution, is there any facebook sharing successful callback api?</p></li>
  </ol>