event.X和event.clientX屬性參考分析

來源:互聯網
上載者:User

event.clientX返回事件發生時,mouse相對於客戶視窗的X座標
event.X也一樣
但是如果設定事件對象的定位屬性值為relative
event.clientX不變
而event.X返回事件對象的相對於本體的座標
event對象詳解 ICOOE 2000.3.31 http://www.111cn.net
event代表事件的狀態,例如事件發生的的元素、滑鼠的位置等等,event對象只在事件程序中才有效。

event屬性:

altKey
檢索ALT鍵的目前狀態
可能的值 true為關閉
false為不關閉

button
檢索按下的滑鼠鍵
可能的值: 0 沒按鍵
1 按左鍵
2 按右鍵
3 按左右鍵
4 按中間鍵
5 按左鍵和中間鍵
6 按右鍵和中間鍵
7 按所有的鍵

cancelBubble
設定或檢索當前事件是否將事件控制代碼起泡
可能的值: false 啟用起泡
true 取消該事件起泡

clientX
檢索與視窗用戶端區域有關的滑鼠游標的X座標,屬性為唯讀,沒有預設值。

clientY
檢索與視窗用戶端區域有關的滑鼠游標的Y座標,屬性為唯讀,沒有預設值。

ctrlKey
ctrlKey 檢索CTRL鍵的目前狀態
可能的值 true為關閉
false為不關閉

 代碼如下 複製代碼

<table border=1 cellpadding=15 cellspacing=15 style="position:relative;left:100;top:100">
<tr><td>
<div onclick="show()" style="background:silver;cursor:hand">
Click here to show. 
</div>
</td></tr>
</table>
<script>
function show(){
alert("window.event.x:"+window.event.x+"nwindow.event.y:"+window.event.y+"nevent.clientX:"+event.clientX+"nevent.clientY:"+event.clientY+"nevent.offsetX:"+event.offsetX+"nevent.offsetY:"+event.offsetY+"nwindow.event.screenX:"+window.event.screenX+"nwindow.event.screenY:"+window.event.screenY);
}
</script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.