Get the coordinates of the current focus through JS
The coordinates to get the current focus are as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<meta http-equiv= "x-ua-compatible" content= "Ie=emulateie7"/>
<meta name= "Auther" content= "Fq"/>
<title> get mouse coordinates </title>
<body>
<script type= "Text/javascript" >
function mouseposition (EV) {
if (Ev.pagex | | ev.pagey) {
return {x:ev.pagex, y:ev.pagey};
}
return {
X:ev.clientx + Document.body.scrollleft-document.body.clientleft,
Y:ev.clienty + document.body.scrolltop-document.body.clienttop
};
}
function MouseMove (EV) {
EV = EV | | window.event;
var mousepos = mouseposition (EV);
document.getElementById (' xxx '). Value = mousepos.x;
document.getElementById (' yyy '). Value = Mousepos.y;
}
Document.onmousemove = MouseMove;
</script>
X:<input id= "xxx" type= "text"/> y:<input id= "yyy" type= "text"/>
</body>