0

Using JS or jquery I need to get the height of the html page that is the src of an iframe. This is what I have and it is not returning a value.

var iFrameID = document.getElementById('myframe');
iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight;

Yes, I am trying to set the height of my iframe this way (the common problem of resizing the iframe based on content). I just know that the iFrameID.contentWindow.document.body.scrollHeight is not giving me a height value for the source page. This problem does not happen in Firefox.

EDIT: This is for offline use. I don't know if that makes any difference.

preahkumpii
  • 1,301
  • 4
  • 21
  • 36
  • Firefox correctly returns a value for `iFrameID.contentWindow.document.body.scrollHeight`. Chrome is not returning a value. – preahkumpii May 05 '12 at 10:19
  • I also tried `$('iframe').contents().find('body').height()`, but it returns 'null'. – preahkumpii May 05 '12 at 10:33
  • possible duplicate of [jquery get height of iframe content when loaded](http://stackoverflow.com/questions/3846132/jquery-get-height-of-iframe-content-when-loaded) – epascarello May 05 '12 at 12:09
  • I have spent way too much time trying to implement the answer on that page, but to no avail, which is why I posted a new question. – preahkumpii May 05 '12 at 12:36

0 Answers0