title: jQuery window/popup function executing too early
body: <p>I'm sorry for posting a "semi-duplicate", but I've stopped getting answers in another question because it seems answered.</p>
  
  <p>Question related to: <a href="https://stackoverflow.com/questions/8521728/jquery-target-different-window-popup">jQuery target different window/popup</a>.</p>
  
  <p>So, i have this function which when fired creates a new window/popup. The problem is that jQuery is supposed to be listening for when the new popup is closed and do an alert, but the alert is fire as soon as the popup is created.</p>
  
  <p>the code:</p>
  
  <pre><code>function idealPopUp(url){
      var windowName = "idealPopUpWindow";
      var windowSize = 'height=820,width=704,toolbar=no,scrollbars=yes';
  
      var idealPopUpWindow = window.open(url, windowName, windowSize);
  
      $(idealPopUpWindow).unload( function () {
          alert("BING");
      });
      event.preventDefault();
  }
  </code></pre>