Hi all,
I'm using the following code to get the mouse coordinates on an image click event. Works fine in IE, gives the following in NS and FF
e has no properties
here's the code:
function getMouse(e) {
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
alert(e); //returns undefined
if (e.pageX || e.pageY)
{
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY)
{
posx = e.clientX + document.body.scrollLeft + document.documentElement.s
crollLeft;
posy = e.clientY + document.body.scrollTop + document.documentElement.s
crollTop;
}
mouseX = posx;
mouseY = posy;
// posx and posy contain the mouse position relative to the document
// Do something with this information
}
So what am I doing wrong?
Thanks
Start Free Trial