title: How to get the scroll position of content thats inside of an iframe
body: <p>I have an html page that contains an iframe loading up some arbitrary page.</p>
  
  <pre><code>&lt;iframe id="siteframe" style="width: 400px; height: 400px;" src="http://www.cnn.com"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>I want to be able to get the scroll position of the page <em>inside</em> the iframe in javascript/jquery. I am still a bit green when it comes to html/js stuff but I've tried a few different variations of using scrollTop and scrollLeft, but had no success. Here is one that didn't work:</p>
  
  <pre><code>write($("#siteframe").contents().scrollLeft() + ", " + $("#siteframe").contents().scrollTop());
  </code></pre>
  
  <p>this one doesn't ever write anything (write is a method that just appends to the text on the screen).</p>
  
  <p>if I remove the <code>.contents()</code> like this:</p>
  
  <pre><code>write($("#siteframe").scrollLeft() + ", " + $("#siteframe").scrollTop());
  </code></pre>
  
  <p>it at least writes something to the screen but it is always 0,0 no matter where the actuall scroll position in the iframe is.</p>
  
  <p>What is the proper way to obtain the x,y position of the content within the iframe in javascript so that my outside page (that contains the iframe) can use it?</p>