5

I want to access and modify the iframe content. when I do it like this, Chrome 16 and Firefox 9 return "Cannot read property 'document' of undefined". What I am doing wrong?

<iframe id="frame"></iframe>

...

var myIFrame = document.getElementById("frame");
var content = myIFrame.contentDocument.document.body.innerHTML;
alert(content);
user1146657
  • 194
  • 3
  • 15
  • 1
    use the solution here: http://stackoverflow.com/questions/7570496/getting-the-document-object-of-an-iframe – Afshin Jan 12 '12 at 23:52

0 Answers0