title: Access parent window scroll event from child inside iframe with Jquery
body: <p>I have a small javascript/jquery script on page1 (an aspx page) that scrolls an iframe loaded with page2 so that it stays with you on the page as you scroll up and down page1.  However, when I load page1 inside an iframe for another parent page the scroll affect doesn't work.</p>
  
  <p>I've tried using window.parent in the calls, but the script still doesn't activate and scroll the page2 iframe as you scroll page1 within the iframe of the parent page (another aspx page).  I hope that makes sense.  </p>
  
  <p>Here is the script I've tried:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          $(window.parent.document).ready(function () {
              var $scrollingDiv = $("#IframeDir");
  
              $(window.parent).scroll(function () {
                  $scrollingDiv
                  .stop()
                  .animate({ "marginTop": ($(window.parent).scrollTop() + -10) + "px" }, "slow");
  
              });
          });
  
  
      &lt;/script&gt;
  </code></pre>
  
  <p>It works if I just load page1 in it's own tab or window, but if I load page1 within an iframe into the parent page, it doesn't seem to see the scroll event of the parent page.</p>
  
  <p>Thanks in advance for any suggestions!
  Erin</p>