複製鏈接
請複製以下鏈接發送給好友

clientX

鎖定
clientX 事件屬性返回當事件被觸發時鼠標指針相對於瀏覽器頁面(或客户區)的水平座標。客户區指的是當前窗口。 [1] 
中文名
clientX
客户區
指的是當前窗口
註    釋
轉換為文檔座標的標準方法
語    法
event.clientX

clientX語法

event.clientX

clientX提示和註釋

註釋:2 級 DOM 沒有提供把窗口座標轉換為文檔座標的標準方法。在 IE 以外的瀏覽器,使用 window.pageXOffset 和 window.pageYOffset 即可。

clientX實例

下面的例子可顯示出事件發生時鼠標指針的座標:
<html>
<head>
<script type="text/javascript">
function show_coords(event)
{ x=event.clientX y=event.clientY 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 mouse pointer.</p>
</body>
</html>
參考資料