Note: if you don't wait to do this after the page loads, it often doesn't work...hence I use the onload() event (which I learned from John)
<BODY onload="test()">
<IFRAME src="test.html" name="read_me_name" id="read_me"></IFRAME>
</BODY>

<script type="text/javascript">
function test() 
{
   var my_frame = document.getElementById("read_me");
   var doc = my_frame.contentDocument;
   if (doc == undefined)
   {
      doc = my_frame.contentWindow.document;
   }

   // read by id
   el = doc.getElementById("read_me_too");
   alert(el.innerHTML);

   // read the entire contents
   alert(doc.body.innerHTML);
}

</script>

(HTML source for the IFRAME)
<HTML>
<DIV id="read_me_too">
<I>Some <B>Html</B> here</I>
</DIV>
</HTML>

-- MattWalsh - 23 Mar 2007

Topic revision: r1 - 23 Mar 2007 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback