File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes X and Y coordinates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "X and Y coordinates" Watch "X and Y coordinates" New topic
Author

X and Y coordinates

Kodo Tan
Ranch Hand

Joined: Aug 14, 2001
Posts: 105
Hi all
Anyone knows the HTML syntax for capturing the X and Y coordinates of the mouse that is compatible to both Netscape and IE browsers ?
Regards.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

not offhand but here is where i would look http://www.w3.org/TR/REC-html32.html
or http://www.w3schools.com/html/html_reference.asp


SCJP
Visit my download page
A1ien51 CNEUFOs
Greenhorn

Joined: Nov 05, 2001
Posts: 16
Here is the code, I put the output into text boxes;

<html>
<head>
<script>
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var Xtemp = 0;
var Ytemp = 0;
function getMouseXY(e) {
if (IE) {
Xtemp = event.clientX + document.body.scrollLeft;
Ytemp = event.clientY + document.body.scrollTop;
}
else {
Xtemp = e.pageX;
Ytemp = e.pageY;
}
if (Xtemp < 0){Xtemp = 0;}
if (Ytemp < 0){Ytemp = 0;}
document.ShowLoc.XMousePos.value = Xtemp;
document.ShowLoc.YMousePos.value = Ytemp;
return true
}
</script>
</body>
</head>
<body>
<form name="ShowLoc">
X Position:<input type="text" name="XMousePos" value="0" size="5"><br>
Y Position:<input type="text" name="YMousePos" value="0" size="5"><br>
</form>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: X and Y coordinates