title: Getting the document object of an iframe
body: <p>I'm trying to get the document object of an iframe, but none of the examples I've googled seem to help.  My code looks like this:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script&gt;
              function myFunc(){
                  alert("I'm getting this far");
                  var doc=document.getElementById("frame").document;
                  alert("document is undefined: "+doc);
              }
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;iframe src="http://www.google.com/ncr" id="frame" width="100%" height="100%" onload="myFync()"&gt;&lt;/iframe&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have tested that I am able to obtain the iframe object, but .document doesn't work, neither does .contentDocument and I think I've tested some other options too, but all of them return undefined, even examples that are supposed to have worked but they don't work for me.  So I already have the iframe object, now all I want is it's document object.  I have tested this on Firefox and Chrome to no avail.</p>