Jquery $(window).height() function does not return actual window height Jquery $(window).height() function does not return actual window height jquery jquery

Jquery $(window).height() function does not return actual window height


Look at your HTML souce code.The first line should be <!DOCTYPE html> and you have <style> tag instead.

So it seems that your document is running in Quirks Mode and jQuery can't calculate correct window dimensions.


//works in chrome$(window).bind('scroll', function(ev){    //get the viewport height. i.e. this is the viewable browser window height    var clientHeight = document.body.clientHeight,        //height of the window/document. $(window).height() and $(document).height() also return this value.        windowHeight = $(this).outerHeight(),        //current top position of the window scroll. Seems this *only* works when bound inside of a scoll event.        scrollY = $(this).scrollTop();    if( windowHeight - clientHeight === scrollY ){        console.log('bottom');    }});


I had the same problem.I've found some things:

1) the problem happens when you try to get the actual height before document is completed rendered;2) the problem happens in google chrome when you does not use corret DOCTYPE (mentioned above)3) it always happens in google chrome even after the document is rendered completly.

For google chrome, I've found a workaround here: get-document-height-cross-browserI'm using this solution only for google chrome and it resolved my problem, I expect helps someone that still have the problem.