Is there any way to get the visible height of the whole page from inside an iframe
, $(window).height()
gives me the iframe
s height?
$(window). height() gives you the height of the view pane. $(window). height() works better as it's cross-browser.
The . height() method is recommended when an element's height needs to be used in a mathematical calculation. This method is also able to find the height of the window and document. $( document ).
Basically, $(window). height() give you the maximum height inside of the browser window (viewport), and $(document). height() gives you the height of the document inside of the browser. Most of the time, they will be exactly the same, even with scrollbars.
You can use the window. innerHeight property to get the viewport height, and the window. innerWidth to get its width. let viewportHeight = window.
If you are using frames, you can get the height of the outermost window by using window.top
in the jQuery constructor. The height of window.top
will get the height of the browser window.
$(window.top).height();
Edit: Updated window.top reference as Mozilla moved their documentation around.
I have always used this implementation
window.innerHeight or document.body.clientHeight or document.documentElement.clientHeight
depending on the browser.
But i don't see why jquery's $(window).height() wont work for your visible height ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With