title: Can I bind a function to the onscroll event of the parent window?
body: <p>I have a page that does not load jQuery. An <code>&lt;iframe&gt;</code> included on that page (in the same domain) does load jQuery.</p>
  <p>Using jQuery, is it possible to bind a function to an event of the <code>window</code> object of the parent page, even though it doesn't load jQuery?</p>
  <p>Accessing the parent <code>window</code> doesn't seem to be a problem; this works (at least in Firefox 4):</p>
  <pre><code>console.log($(parent)); // displays &quot;jQuery(Window index.html)&quot; in the console
  </code></pre>
  <p>To give some context, I'm developing the document to be loaded within the <code>&lt;iframe&gt;</code>, but I don't control the parent page, so I can't use a solution that requires adding jQuery to it. Ultimately I want to subscribe to the <code>onscroll</code> event of the parent <code>window</code> to execute a function in the <code>&lt;iframe&gt;</code> every time that scrolling happens in the viewport.</p>
  <p>I've tried (within the <code>&lt;iframe&gt;</code>):</p>
  <pre><code>function my_function() {
    console.log('Scrolling...');
  }
  $(parent).scroll(my_function);
  </code></pre>
  <p>However, that didn't work.</p>
  <p>Any help would be appreciated.</p>
  <p>Here is a working example:</p>
  <p><a href="http://troy.onespot.com/static/stack_overflow/onscroll/parent.html" rel="nofollow noreferrer">http://troy.onespot.com/static/stack_overflow/onscroll/parent.html</a></p>
  <p>The document in the <code>&lt;iframe&gt;</code> is here:</p>
  <p><a href="http://troy.onespot.com/static/stack_overflow/onscroll/iframe.html" rel="nofollow noreferrer">http://troy.onespot.com/static/stack_overflow/onscroll/iframe.html</a></p>