JavaScript Event object "Go"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.