Just use
$(document).height()
and / or
$(window).height()
instead of $ ('body'). height ()
To expand the bit,
$(window).height(); // returns height of browser viewport $(document).height(); // returns height of HTML document
As Bajmegakapa points out, there is a slight difference, albeit a few pixels. The true body height can be calculated by subtracting the body offset from the height of the document (as I mentioned above):
$(document).height() - $('body').offset().top
Norse source share