Ravindar, Biztalk Developer and Administrator

Just another BizTalk blog

grab the mouse pointer location in the browser

call the follwing function in body tag

onload=”setCoordinates();TraceXY(window.event);”

//this method is used to track the mouse cursor location
function setCoordinates()
{
document.onmousemove=TraceXY
}

function TraceXY(e)
{
var isOpera, isIE, isNav, isFox, isOther = false;
if (navigator.userAgent.indexOf(“Opera”)!=-1)
{
isOpera = true;
}
else if (navigator.userAgent.indexOf(“Firefox”)!=-1)
{
isFox = true;
}
else if (navigator.appName == “Microsoft Internet Explorer”)
{
isIE = true;
}
else if (navigator.appName == “Netscape”)
{
isNav = true;
}
else
{
isOther = true;
}
if (isIE)
{
document.getElementById(‘MouseXPosition’).value = event.clientX + document.body.scrollLeft;
document.getElementById(‘MouseYPosition’).value= event.clientY + document.body.scrollTop-70;
}
else
{
document.getElementById(‘MouseXPosition’).value=e.pageX;
document.getElementById(‘MouseYPosition’).value=e.pageY;
}
}

Advertisements

February 2, 2010 - Posted by | Java Script

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: