Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Finding co-ordinates of Mouse


Message #1 by "Ben Smith" <ben@b...> on Tue, 20 Feb 2001 13:39:49 -0000
Here's a partial solution - requires Javascript1.2 so works in NS4 doesn't 
work in IE4, don't know about IE5.
<HTML>
<HEAD>
<TITLE>Mouse Position</TITLE>
<SCRIPT LANGUAGE="javascript1.2">
<!--
function window_onload() {
        window.captureEvents(Event.MOUSEUP);
        window.onmouseup = showPos;
}
function window_onunload() {
        window.releaseEvents(Event.MOUSEUP);
}
function showPos(evt) {
        alert("X=" + evt.pageX + ", Y=" + evt.pageY);
}
//-->
</SCRIPT>
</HEAD>
<BODY onload="return window_onload()" onunload="return window_onunload()">
<P>Click the mouse to see X and Y position...</P>
</BODY>
</HTML>

Phil

> Hi
> 
> I'm currently developing a site which has to have a dynamic menu system.
> I've got so far but I'm stuck at one little detail.
> 
> When the user clicks the left mouse button, is there anyway at all to 
find
> the X Y co-ordinates of the pointer?
> 
> Any suggestions greatly appreciated,
> 
> Thanks in advance,
> 
> 
> Ben Smith

  Return to Index