急:在网页里如何知道鼠标在网页上的坐标

急:在网页里如何知道鼠标在网页上的坐标
---------------------------------------------------------------

 1<html>
 2<body onmousemove="f()">
 3<input id="aa"/>
 4<script>   
 5function f(){   
 6aa.value="x:"+window.event.x+" y:"+window.event.y;   
 7}   
 8</script>
 9</body>
10</html>

---------------------------------------------------------------

event.clientX

Retrieves the x-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.

event.clientY

Retrieves the y-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.

event.offsetX

Sets or retrieves the x-coordinate of the mouse pointer's position relative to the object firing the event.

event.offsetY

Sets or retrieves the y-coordinate of the mouse pointer's position relative to the object firing the event.

event.screenX

Retrieves the x-coordinate of the mouse pointer's position relative to the user's screen.

event.screenY

Retrieves the y-coordinate of the mouse pointer's position relative to the user's screen.

event.x

Retrieves the x-coordinate of the mouse pointer's position relative to the parent element.

event.y

Retrieves the y-coordinate of the mouse pointer's position relative to the parent element.

Published At
Categories with Web编程
comments powered by Disqus