I am having problem of getting wrong height with
$(window).height();
and got the similar question here
In my case when I try
This fixed me
var width = window.innerWidth;
var height = window.innerHeight;
Well you seem to have mistaken them both for what they do.
$(window).height()
gets you an unit-less pixel value of the height of the (browser) window aka viewport. With respect to the web browsers the viewport here is visible portion of the canvas(which often is smaller than the document being rendered).
$(document).height()
returns an unit-less pixel value of the height of the document being rendered. However, if the actual document’s body height is less than the viewport height then it will return the viewport height instead.
Hope that clears things a little.
$(document).height:
if your device height
was bigger. Your page has Not any scroll;
$(document).height:
assume you have not scroll and return this height
;
$(window).height:
return your page height
on your device.
you need know what it is mean about document and window.
AFAIK $(window).height();
returns the height of your window and $(document).height();
returns the height of your document