This paper illustrates the method of getting the coordinate value of the mouse in JS Web page. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Display mouse coordinates </title>
<body onmousemove= "Micro$oftmousemove ()" >
<script language= "JavaScript" >
if (navigator.appname = ' Netscape ')
{
Document.captureevents (Event.mousemove);
Document.onmousemove = Netscapemousemove;
}
function Netscapemousemove (e) {
if (E.screenx!= document.test.x.value && e.screeny!= document.test.y.value);
{
Document.test.x.value = E.screenx;
Document.test.y.value = E.screeny;
}
}
function Micro$oftmousemove () {
if (window.event.x!= document.test.x.value && window.event.y!= document.test.y.value);
{
Document.test.x.value = Window.event.x;
Document.test.y.value = Window.event.y;
}
}
</SCRIPT>
<form name= "Test" >
X: <input type= "TEXT" name= "x" size= "4" >
Y: <input typue= "TEXT" name= "y" size= "4" >
</FORM>
</body>
I hope this article will help you with your JavaScript programming.