title: How to have jQuery refer to a newly popped up window?
body: <p>In the django function showRelatedObjectLookupPopup, I'd like to bind a function to a button in the newly popped up window, but I don't know how to refer to the new window. Here is what I have tried:</p>
  
  <pre><code>function showRelatedObjectLookupPopup(triggeringLink) {
  // other function stuff omitted
      var name = triggeringLink.id.replace(/^lookup_/, '');
      name = id_to_windowname(name);
      var win = window.open(href, name, 500, 700, resizable=yes, scrollbars=yes');
  
      win.onload = function () {
           $(document).ready(function() {
                 $("input.default").hover(function () {alert('hovered')})})};
      win.focus();
      return false;
  }
  </code></pre>
  
  <p>But this binds to the button in the original window.</p>