clientY 事件屬性

定義和用法
clientY 事件屬性返回當事件被觸發時鼠標指針向對于瀏覽器頁面(客戶區)的垂直坐標??蛻魠^指的是當前窗口。
語法
event.clientY
實例
實例
下面的例子可顯示出事件發生時鼠標指針的坐標:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在線教程(w3cschool.cn)</title>
<script>
function show_coords(event){
var x=event.clientX;
var y=event.clientY;
alert("X coords: " + x + ", Y coords: " + y);
}
</script>
</head>
<body>
<p onmousedown="show_coords(event)">請在文檔中點擊。一個消息框會提示出鼠標指針的 x 和 y 坐標。</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在線教程(w3cschool.cn)</title>
<script>
function show_coords(event){
var x=event.clientX;
var y=event.clientY;
alert("X coords: " + x + ", Y coords: " + y);
}
</script>
</head>
<body>
<p onmousedown="show_coords(event)">請在文檔中點擊。一個消息框會提示出鼠標指針的 x 和 y 坐標。</p>
</body>
</html>
嘗試一下 ?
