1

I'm trying to get the content height of one of the iframes in a webpage using javascript.

but obj.contentWindow.document.body.scrollHeight always gives 150px (or the height of the iframe element itself if I set it to a default value).

Both the parent HTML page and the iframe content are local on my PC and share the same folder.

Any suggestions?

the relevant parts of my code:

...

<iframe id="I2" name="Content" src="home.html" style="width: 860px; margin-left: 330px; top: 0px; border: none; overflow:hidden" 
     scrolling="no" 
     onload="onloadingContent(this)">
</iframe>

...

<script>
function onloadingContent(obj) 
{
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
} 

...
2
  • yes, post your code and css Jul 21, 2015 at 8:48
  • edited the question - added the code
    – pHbits
    Jul 21, 2015 at 8:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.