screenX 事件屬性
定義和用法
screenX 事件屬性可返回事件發(fā)生時(shí)鼠標(biāo)指針相對(duì)于屏幕的水平坐標(biāo)。
語(yǔ)法
event.screenX
實(shí)例
下面的例子可顯示出事件發(fā)生時(shí)鼠標(biāo)指針的坐標(biāo):
<html> <head> <script type="text/javascript"> function show_coords(event) { x=event.screenX
y=event.screenY
alert("X coords: " + x + ", Y coords: " + y) } </script> </head> <body onmousedown="show_coords(event)"> <p>Click in the document. An alert box will alert the x and y coordinates of the cursor.</p> </body> </html>
TIY
- screenX
- 提示鼠標(biāo)指針的坐標(biāo)。