Recently, website development page statistics have been developed in the past, but the functions are not very full. Therefore, we will use some good functions this time.
For example, in this case, the JS cursor/mouse coordinates of the page may ask you what is the use. Baidu statistics has a hotspot Statistical Chart. Now you can understand it clearly.
Okay, mount the meat:
Function: obtains the pixel coordinates of the cursor.
Copy codeThe Code is as follows:
<Html>
<Head>
<Script type = "text/javascript">
Function showPosition (e ){
Var x, y;
Var e = e | window. event;
Document. getElementById ("x"). value = e.clientx?document.body.scrollleft;document.doc umentElement. scrollLeft;
Document. getElementById ("y"). value = e.clienty?document.body.scrolltop=document.doc umentElement. scrollTop
}
</Script>
</Head>
<Body>
<Div onmousemove = "showPosition (event);" style = "height: 100%; width: 100%;">
X: <input id = "x" type = "text" value = ""/>
Y: <input id = "y" type = "text" value = ""/>
</Div>
</Body>
</Html>