English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i'm looking for a script that is cross browser compatible to get the mouse location when the mouse is moved over a link.

this is my current code however it doesn't work in IE and i'm not really sure what i'm doing.


Link


var mouseX = event.clientX;
var mouseY = event.clientY;

thanks for the help

2007-03-19 16:41:04 · 2 answers · asked by Brady 3 in Computers & Internet Programming & Design

The error i'm getting is 'event' is undefined... do i need to pass it or initialize it in any way?

2007-03-19 16:58:00 · update #1

okay i'm sorry.. ignore the above... i have isolated the error and probably should start a different question.. but here is my problem. There is no pageX or pageY in IE, so how do i get the coords of the mouse relative to the whole page not just the visible window?

2007-03-19 17:04:28 · update #2

wonderful link!.. thank you both for the help. i'll choose you as best in a couple hours when i can

2007-03-19 17:58:27 · update #3

2 answers

make your own event!
function someHandler(a,x,y){
alert(a.type);
}

onclick="someHandler(event,'x','y'); return false;">
Do it


a is your event!

UPDATE!
Most browsers provide both pageX/Y and clientX/Y. Internet Explorer is the only current browser that provides clentX/Y, but not pageX/Y.

See this link to fake it for IE!


SECOND UPDATE!
I'm glad we got this worked out! it's been a long time since I had to get into the dirtiness that is IE! I use http://jquery.com library and most of those horrible details are hidden from us!

Cross Platform Cross Browser is the only way to fly!

2007-03-19 17:05:33 · answer #1 · answered by jake cigar™ is retired 7 · 1 0

I've got a similar code snip that does work in IE and FF (but probably not older versions of netscape due to the document.getElementbyId). I use an image but I think you can substitute any object with an ID, so... (sorry I haven't tested this):

Link



Edit: wow, those ...'s are wacky. Make sure you hover over them to get the whole code.

2007-03-19 23:48:28 · answer #2 · answered by skatc 3 · 0 0

fedest.com, questions and answers