topical media & game development
#javascript-code-18-scrollX.js / js
// A function for determining how far horizontally the browser is scrolled
function scrollX() {
// A shortcut, in case we’re using Internet Explorer 6 in Strict Mode
var de = document.documentElement;
// If the pageXOffset of the browser is available, use that
return self.pageXOffset ||
// Otherwise, try to get the scroll left off of the root node
( de && de.scrollLeft ) ||
// Finally, try to get the scroll left off of the body element
document.body.scrollLeft;
}
// A function for determining how far vertically the browser is scrolled
function scrollY() {
// A shortcut, in case we’re using Internet Explorer 6 in Strict Mode
var de = document.documentElement;
// If the pageYOffset of the browser is available, use that
return self.pageYOffset ||
// Otherwise, try to get the scroll top off of the root node
( de && de.scrollTop ) ||
// Finally, try to get the scroll top off of the body element
document.body.scrollTop;
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.