NameSilo

JS Scroll detecting Cross browser

Spaceship Spaceship
Watch

crazyluv

Established Member
Impact
2
I am use the following javascript code to detect the scroll movement in various browsers. Mostly IE and FF since those are the only two I got.

Code:
function getScrollMovement(){
	if (typeof(pageXOffset) != "undefined")
	{
		currentX=window.pageXOffset;
		currentY=window.pageYOffset;
	}
	else if (document.compatMode == "CSS1Compat" )
	{
		currentX=document.documentElement.scrollLeft
		currentY=document.documentElement.scrollTop
	}
	else
	{
		currentX=document.body.scrollLeft
		currentY=document.body.scrollTop
	}
}

I was wondering if this code is compatible in other browsers and for most version of the two I have already mentioned.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains

We're social

Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back