HighDots Forums  

Mouse cursor position

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Mouse cursor position in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Danny@Kendal
 
Posts: n/a

Default Mouse cursor position - 11-11-2004 , 12:16 PM






How can I get the coordinates of the mouse cursor in Mozilla browsers as
well as Opera and IE6?
I'm struggling to understand how to capture mouse movement events with
Mozilla/Netscape/Firefox and I've Googled so much my brain hurts.

http://www.ghpkendal.co.uk/TestPages/Test.htm

The following javascript function works for Opera and IE6 when called by
onMouseMove="moveDiv()". How do I adapt it to cope with the browser versions
mentioned above?
The code snippet in question is listed below. I've not included any feature
detection to keep things simple.

divX & divY are locally declared numerical variables in the test page.
'cpos' is the ID of a <div> element used to display the mouse cursor
coordinates.

function movement()
{
divX = event.x
divY = event.y
document.getElementById('cpos').innerHTML = "X=" + divX + "<br>Y=" + divY
}



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.