PHP and javascript snippets you can copy and paste.

Thursday, June 7, 2007

js_get_scrollLeft()

/**
* Gets how much the page has been scrolled left.
*
* Credit: http://www.quirksmode.org/viewport/compatibility.html
*
*/
function js_get_scrollLeft(){

if (self.pageYOffset) // all except Explorer
{
x = self.pageXOffset;
}
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
{
x = document.documentElement.scrollLeft;
}
else if (document.body) // all other Explorers
{
x = document.body.scrollLeft;
}

return x;

}

No comments: