clientY 事件屬性
定義和用法
clientY 事件屬性返回當(dāng)事件被觸發(fā)時鼠標(biāo)指針向?qū)τ跒g覽器頁面(客戶區(qū))的垂直坐標(biāo)。
客戶區(qū)指的是當(dāng)前窗口。
語法
event.clientY
提示和注釋
注釋:注意,該坐標(biāo)不考慮文檔的滾動。如果事件發(fā)生在窗口的頂部,無論文檔滾了多遠(yuǎn),clientY 的值都是 0。但是,2 級 DOM 沒有提供把窗口坐標(biāo)轉(zhuǎn)換為文檔坐標(biāo)的標(biāo)準(zhǔn)方法。在 IE 以外的瀏覽器,使用 window.pageXOffset 和 window.pageYOffset 即可。
實(shí)例
下面的例子可顯示出事件發(fā)生時鼠標(biāo)指針的坐標(biāo):
<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>
TIY
- clientY
- 顯示鼠標(biāo)指針的坐標(biāo)。