E. buttonW3C is used to obtain the mouse Key 0. The left key 1 indicates the middle key 2 indicates the right click, while the IE browser 1 indicates the left Key 4 indicates the middle 2 indicates the right click. The IE browser here is mainly a browser under IE8, if you are interested, refer
The Code is as follows:
Document. onmousedown = function (e ){
Alert (getButton (e) // e. button W3C is used to obtain the mouse Key 0. The left key 1 indicates the middle key 2 indicates the right click, while the IE browser 1 indicates the left Key 4 indicates the middle 2 indicates the right click. Here, the IE browser is mainly a browser under IE8.
};
Function getButton (e ){
/*
1. Both IE and Chrome support the window. event attribute.
2. Chrome also supports W3C
3. If both W3C and IE support, W3C has been standardized.
*/
If (e) {// Chrome is based on W3C as the first judgment.
Return e. button;
} Else if (window. event ){
Switch (window. event. button ){
Case 1: return 0; // return the value of the left mouse button
Case 4: return 1; // return the value of the middle mouse key.
Case 2: return 2; // return the right-click Value
Case 0: return 2; // the value of the right mouse button returned is mainly 360. the browser returns 0 in IE, which indicates the value returned when the mouse key is not pressed.
};
};
};