How to get the content of the iframe in a webpage with iframe

The iframe shows the content of the file it loads. In a webpage with a iframe, how to get the content of the iframe? Here is an example:

on the webpage:

<iframe id=”upload_target” name=”upload_target”></iframe>

javascript:

var xx = document.getElementById(‘MyIFrame’).contentDocument.body.innerHTML;
alert(xx);

I have tested it under IE8、firefox 3.6.12、Google Chrome 7.0.517.44, it all works.

Leave a Reply

Your email address will not be published. Required fields are marked *