jquery $(window).height() is returning the document height
With no doctype
tag, Chrome reports the same value for both calls.
Adding a strict doctype like <!DOCTYPE html>
causes the values to work as advertised.
The doctype
tag must be the very first thing in your document. E.g., you can't have any text before it, even if it doesn't render anything.
I had the same problem, and using this solved it.
var w = window.innerWidth;
var h = window.innerHeight;
I think your document must be having enough space in the window to display its contents. That means there is no need to scroll down to see any more part of the document. In that case, document height would be equal to the window height.
Here's a question and answer for this: Difference between screen.availHeight and window.height()
Has pics too, so you can actually see the differences. Hope this helps.
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.