Last active
October 6, 2015 13:57
-
-
Save 50percentgrey/53a1f869fe0fd332d4b3 to your computer and use it in GitHub Desktop.
scrolltop all browsers
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
// scrolltop all browsers | |
function getScrollTop(){ | |
if(typeof pageYOffset!= 'undefined'){ | |
//most browsers except IE before #9 | |
return pageYOffset; | |
} | |
else{ | |
var b = document.body; //IE 'quirks' | |
var d = document.documentElement; //IE with doctype | |
d = (d.clientHeight)? d: b; | |
return d.scrollTop; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment