• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

X and Y coordinates

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
reply
    Bookmark Topic Watch Topic
  • New Topic