html获取鼠标按键数,鼠标在IE、Firefox和Opera点击键所对应的数字代码
一、IE
左鍵是 window.event.button = 1
右鍵是 window.event.button = 2
中鍵是 window.event.button = 4
沒有按鍵動作window.event.button = 0
二、Firefox
左鍵是 event.button = 0
右鍵是 event.button = 2
中鍵是 event.button = 1
沒有按鍵動作 event.button = 0
三、Opera 7.23/7.54
鼠標左鍵是 window.event.button = 1
沒有按鍵動作 window.event.button = 1
右鍵和中鍵無法獲取
四、Opera 7.60/8.0
鼠標左鍵是 window.event.button = 0
沒有按鍵動作 window.event.button = 0
右鍵和中鍵無法獲取
另外:屏蔽右鍵的是window.event.button = 3
Window.event對象代表事件的狀態,例如觸發event對象的元素、鼠標的位置及狀態、按下的鍵等等。
Window.event對象只在事件發生的過程中才有效。
Window.event的某些屬性只對特定的事件有意義。比如,fromElement 和 toElement 屬性只對 onmouseover 和 onmouseout 事件有意義。
如果事件觸發后,鼠標移出窗口外,則返回的值為 -1 ,這是個只讀屬性。這意味著,你只能通過它來得到鼠標的當前位置,卻不能用它來更改鼠標的位置。
Event對象的屬性有:
altKey, button, cancelBubble, clientX, clientY, ctrlKey, fromElement, keyCode, offsetX, offsetY, propertyName, returnValue, screenX, screenY, shiftKey, srcElement, srcFilter, toElement, type, x, y
總結
以上是生活随笔為你收集整理的html获取鼠标按键数,鼠标在IE、Firefox和Opera点击键所对应的数字代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html页面渲染vue组件,Vue组件页
- 下一篇: add1顶部菜单html,add1.ht