Jonne wrote:
[...]
Is the only way to get mouse coordinates this:
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}
?
You should make your event capture routine more cross-browser and
swap feature detection for browser detection:
function getMouseXY(e) {
var e = e || window.event;
// grab the x-y pos.s if browser supports clientX/Y
if ( e.clientX && document.body.scrollLeft
&& document.body.scrollTop ) {
tempX = e.clientX + document.body.scrollLeft;
tempY = e.clientY + document.body.scrollTop;
// Otherwise, try pageX/Y
} else if (e.pageX) {
...
}
I imagine you also need to get the postion of the element too,
for that document.getElementById may be useful to get a reference
to the div.
Have a read here for a pointer to the issues with trying to get
the cursor position:
<URL:http://www.quirksmode.org/js/events_properties.html>
--
Fred