Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jquery

dom

iframe

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.

like image 796
Fred Wilson Avatar asked Apr 09 '09 16:04

Fred Wilson


People also ask

How do I transfer data from iframe to parent?

Sending data from child iframe to parent window : Whenever you embed an iframe, the iframe will have a reference to the parent window. You just need to use the PostMessage API to send data via the window. parent reference of the parent window.


2 Answers

jQuery is not needed.

parent.document.body.clientHeight

That works for me with IE7 and FF3.

like image 183
Thinker Avatar answered Oct 11 '22 01:10

Thinker


In jQuery you can do

$(parent.window).width();
like image 36
Kld Avatar answered Oct 11 '22 00:10

Kld