Created
October 17, 2012 09:04
-
-
Save zhuzhuaicoding/3904600 to your computer and use it in GitHub Desktop.
scrollTop compatitable way
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
| function getScrollTop(){ | |
| var position = [0, 0]; | |
| if (typeof window.pageYOffset != 'undefined') { | |
| position = [ | |
| window.pageXOffset, window.pageYOffset]; | |
| } else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) { | |
| position = [ | |
| document.documentElement.scrollLeft, document.documentElement.scrollTop]; | |
| } else if (typeof document.body.scrollTop != 'undefined') { | |
| position = [ | |
| document.body.scrollLeft, document.body.scrollTop]; | |
| } | |
| return position; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment