How to get the maximum scroll position of a page precisely?

Viewed 2020

If I use the formula

document_height - window_height = max_scroll_position

It evaluates to 1 or 0, although I believe it should consistently evaluate to 0. For e.g, on firefox Open console, Scroll to the bottom of the page on http://stackoverflow.com and do the following on console :

($(document).height() - $(window).height()) - $(document).scrollTop()

I get 1 as the answer (remember to keep the scroll position to bottom most) On jquery.com however, doing the above gives 0

What am I missing ?

1 Answers
Related