A Event Object
Event handling consists of three parts: an object. The event handler function = function. For example, click anywhere in the document.
1. mouse button
Button properties in non-IE (Internet Explorer)
0 indicates the primary mouse button (general is the left mouse)
1 indicates the middle mouse button (mouse wheel button)
2 indicates the secondary mouse button (general is the right mouse key)
The Button property in IE
0 means the button is not pressed
1 indicates the primary mouse button (general is the left mouse)
2 indicates the secondary mouse button (general is the right mouse key)
3 indicates that the primary and secondary mouse buttons are pressed at the same time
4 means that the middle mouse button is pressed
5 means that both the primary mouse button and the middle mouse button are pressed
6 means the mouse button is pressed at the same time and the middle button
7 indicates that three mouse buttons are pressed at the same time
function Getbutton (evt) {//cross-browser right-click the corresponding
var e = evt | | window.event;
if (evt) {//chrome browser supports web and IE
return E.button; Be aware of the order of Judgment
} else if (window.event) {
Switch (E.button) {
Case 1:return 0;
Case 4:return 1;
Case 2:return 2;
}
}
}
Document.onmouseup = function (evt) {//Call
if (Getbutton (evt) = = 0) {
Alert (' Press the left button! ‘);
} else if (Getbutton (evt) = = 1) {
Alert (' Press the middle button! ‘);
} else if (Getbutton (evt) = = 2) {
Alert (' Press the right button! ‘ );
}
}
2. Visual area and screen coordinates
E.clientx +document.documentelement.scrolltop+ ', ' + e.clienty//chrome to be used Document.body.scrollTop
Reprinted from: http://www.cnblogs.com/sctnl/p/6016503.html
JavaScript Event object "Go"