How to get the height of an iframe with javascript from inside the iframe? What about pages with multiple iframes?

Posted by VKen on Stack Overflow See other posts from Stack Overflow or by VKen
Published on 2011-02-23T05:14:31Z Indexed on 2011/02/23 7:24 UTC
Read the original article Hit count: 80

Filed under:
|
|
|
|

Hi all,

Is there a way to detect the height and width of an iframe, by executing a script from inside the iframe? I need to dynamically position some elements in the iframe according to the different height/width of the iframe.

Would there be any difference if there are multiple iframes in the same page? i.e. each iframe wants to find its own dimensions.

Javascript or jquery solutions welcomed.

Thanks!

<iframe src='http://example.com' width='640' height='480' scrolling='no' frameborder='0' longdesc='http://example.com'></iframe>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery