mousedown事件
event.button | IE | Firefox | Chrome | Opera |
左键 | 1 | 0 | 0 | 0 |
右键 | 2 | 2 | 2 | 2 |
中键 | 4 | 1 | 1 | 1 |
默认 | -- | -- | -- | -- |
测试代码:
IE:document.onmousedown = function(){console.log(window.event.button)} (注:IE不支持window.onmousedown)
non-IE: document.onmousedown = function(e){console.log(e.button)}
mouseup事件
event.button | IE | Firefox | Chrome | Opera |
左键 | 1 | 0 | 0 | 0 |
右键 | 2 | 2 | 2 | 2 |
中键 | 4 | 1 | 1 | -- |
默认 | -- | -- | -- | -- |
测试代码:
IE:document.onmouseup = function(){console.log(window.event.button)}(注:IE不支持window.onmouseup)
non-IE: document.onmouseup = function(e){console.log(e.button)}