Skip to content

Instantly share code, notes, and snippets.

@mroch
Created January 21, 2010 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mroch/283302 to your computer and use it in GitHub Desktop.
Save mroch/283302 to your computer and use it in GitHub Desktop.
getViewportScrollY = function() {
var scrollY = 0;
if( document.documentElement && document.documentElement.scrollTop ) {
scrollY = document.documentElement.scrollTop;
}
else if( document.body && document.body.scrollTop ) {
scrollY = document.body.scrollTop;
}
else if( window.pageYOffset ) {
scrollY = window.pageYOffset;
}
else if( window.scrollY ) {
scrollY = window.scrollY;
}
return scrollY;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment