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

If your iframe’s page and its parent page are served from different domains (meaning you can’t access the parent page’s DOM properties from the iframe page), then I think it’s the same as when you’re trying to work out the viewport height.

For that, see:

  • Get the browser viewport dimensions with JavaScript

Or possibly this:

  • http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/

Be aware that code like this:

var thisIframesHeight = window.parent.$("iframe.itsID").height();

will only be safe if the source of the iframe and parent window are from the same domain. If not you will get permission denied problems and you will have to take another approach.


Each <iframe> would need an id I suppose. And then inside the <iframe> you would reference it like this:

var thisIframesHeight = window.parent.$("iframe#itsID").height();