Created
March 27, 2014 15:42
-
-
Save tunderdomb/9810464 to your computer and use it in GitHub Desktop.
get the scrollable root element on the page
This file contains hidden or 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
| // get the actually scrollable element | |
| function getScrollable( root ){ | |
| if ( !root.nodeName || !!~["iframe", "#document", "html", "body"].indexOf(root.nodeName.toLowerCase()) ) { | |
| var doc = (root.contentWindow || root).document || root.ownerDocument || root | |
| root = /webkit/i.test(navigator.userAgent) || doc.compatMode == "BackCompat" | |
| ? doc.body | |
| : doc.documentElement; | |
| } | |
| return root | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment