Skip to content

Instantly share code, notes, and snippets.

@MaciekBaron
Created April 8, 2013 11:32
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 MaciekBaron/5336138 to your computer and use it in GitHub Desktop.
Save MaciekBaron/5336138 to your computer and use it in GitHub Desktop.
A cross-browser function to retrieve the window's `scrollTop`
function getScrollTop() {
if (typeof window.pageYOffset !== 'undefined'){
return window.pageYOffset;
} else {
var iequirks = document.body;
var iedoctype = document.documentElement;
var doc = (iedoctype.clientHeight) ? iedoctype : iequirks;
return doc.scrollTop;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment