Skip to content

Instantly share code, notes, and snippets.

@jaredmcateer
Created November 29, 2011 22:37
Show Gist options
  • Save jaredmcateer/1406922 to your computer and use it in GitHub Desktop.
Save jaredmcateer/1406922 to your computer and use it in GitHub Desktop.
getWindowScroll: function() {
var T, L, W, H;
var w = window;
with (w.document) {
if (w.document.documentElement && documentElement.scrollTop) {
T = documentElement.scrollTop;
L = documentElement.scrollLeft;
} else if (w.document.body) {
T = body.scrollTop;
L = body.scrollLeft;
}
if (w.innerWidth) {
W = w.innerWidth;
H = w.innerHeight;
} else if (w.document.documentElement && documentElement.clientWidth) {
W = documentElement.clientWidth;
H = documentElement.clientHeight;
} else {
W = body.offsetWidth;
H = body.offsetHeight
}
}
return {
top: T,
left: L,
width: W,
height: H
};
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment