clientX 属性.

Syntax:

  

event.clientX

The clientX event attribute returns the horizontal coordinate (according to the client area) of the mouse pointer when an event was triggered.

The client area is the current window.

e.g:

 1 <html>
 2 <head>
 3 <script>
 4 function show_coords(event)
 5   {
 6   var x=event.clientX
 7   var y=event.clientY
 8   alert("X coords: " + x + ", Y coords: " + y)
 9   }
10 </script>
11 </head>
12 
13 <body>
14 
15 <p onmousedown="show_coords(event)">Click this paragraph, and an alert box will alert the x and y coordinates of the mouse pointer.</p>
16 
17 </body>
18 </html>
View Code

Note that the literal event can not be changed,or it won't work.

posted @ 2013-12-18 02:31  wonkju  阅读(297)  评论(0编辑  收藏  举报