screenX 事件屬性

定義和用法
screenX 事件屬性可返回事件發生時滑鼠指針相對於螢幕的水準座標。
語法
event.screenX
實例
實例
下麵的例子可顯示出事件發生時滑鼠指針的座標:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script type="text/javascript">
function coordinates(event){
x=event.screenX
y=event.screenY
alert("X=" + x + " Y=" + y)
}
</script>
</head>
<body onmousedown="coordinates(event)">
<p>
在文檔中點擊某個位置。消息框會提示出指針相對於螢幕的 x 和 y 座標。
</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script type="text/javascript">
function coordinates(event){
x=event.screenX
y=event.screenY
alert("X=" + x + " Y=" + y)
}
</script>
</head>
<body onmousedown="coordinates(event)">
<p>
在文檔中點擊某個位置。消息框會提示出指針相對於螢幕的 x 和 y 座標。
</p>
</body>
</html>
