(Hope it is not a duplicate because I didn\'t find it when searching and googling)
I am trying to find how to detect in some fixed-height div (\'#div\') when the scroll-
Here's the code from jQuery source:
if (jQuery.isWindow(elem)) {
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
// isn't a whole lot we can do. See pull request at this URL for discussion:
// https://github.com/jquery/jquery/pull/764
return elem.document.documentElement["client" + name];
}
// Get document width or height
if (elem.nodeType === 9) {
doc = elem.documentElement;
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
// unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
return Math.max(
elem.body["scroll" + name], doc["scroll" + name],
elem.body["offset" + name], doc["offset" + name],
doc["client" + name]);
}
So for $(window)
clientHeight is used. Which, as @Drew correctly mentioned the height of visible screen area.
For $(document)
the whole scroll height of the current page will be used.