Handling events with the DOM - Part III - The x-y game: determining mouse coordinates (Page 6 of 7 )
The process of finding mouse position is rather messy and unreliable, because there are six mouse coordinate properties pairs, but they are not really available cross-browser. Due to this fact, most of them are useless for implemented in reliable mouse position detection scripts. The list of properties is shown below:
Once we’ve listed the function, we would call it this way:
Please note that in the case of Mozilla and Netscape, the function will be executed whether we’re left or right clicking on the document. If we’re dealing with IE, which supports the "clientX, clientY" properties, we calculate mouse position by first obtaining the coordinates relative to the client area of the browser and then adding the "scrollLeft" and "scrollTop" values, relative to the document element.
As you can appreciate, mouse coordinate detection is quite difficult to do accurately, due to annoying browser inconsistencies.