-
-
Save matijs/49f0439eda039b7f0911 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* How to get the scrolling element in charge of scrolling the viewport: | |
* | |
* - in Quirks mode the scrolling element is the "body" | |
* - in Standard mode the scrolling element is the "documentElement" | |
* | |
* webkit based browsers always use the "body" element disrespectfull of the specifications: | |
* http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop | |
*/ | |
function getScrollingElement() { | |
var d = document; | |
return d.documentElement.scrollHeight > d.body.scrollHeight && | |
d.compatMode.indexOf('CSS1') == 0 ? | |
d.documentElement : | |
d.body; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment