Within an iFrame, we need to get the parent's window/document height.
Is there a way to get this using jQuery?
I know we can use $(document).height() to get a page's height. I just can't figure out how to get the parent's value from within the iFrame.
Please help!
jQuery is not needed.
parent.document.body.clientHeight
That works for me with IE7 and FF3.
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();
In jQuery you can do
$(parent.window).width();
Another possibility is :
$(window.parent.document).height()