How can I get a parent window's height from within iFrame using jQuery?

jQuery is not needed.

parent.document.body.clientHeight

That works for me with IE7 and FF3.


In jQuery you can do

$(parent.window).width();

I tried the clientHeight approach on a website where both Iframes where on the same domain and it didn't work. (return 0).

After a lot of testing the best way I have found (and I'll be happy to learn a better way) is to create a function on the parent which returns the document height, something like:

Parent:

function getDocumentHeight(){
   return $(document).height();
}

Iframe:

var parentDocHeight = parent.getDocumentHeight();

Tags:

Dom

Jquery

Iframe