Description of the mouse click event in each browser and the event object properties

Source: Internet
Author: User

IE
Left arrow is Window.event.button = 1
Right-click is Window.event.button = 2
Middle key is Window.event.button = 4
No keystroke action Window.event.button = 0

Firefox
Left arrow is Event.button = 0
Right-click is Event.button = 2
Middle key is Event.button = 1
No keystroke action Event.button = 0

Opera 7.23/7.54
Left mouse button is Window.event.button = 1
No keystroke action Window.event.button = 1
Right and Middle keys cannot be obtained

Opera 7.60/8.0
Left mouse button is Window.event.button = 0
No keystroke action Window.event.button = 0
Right and Middle keys cannot be obtained

In addition: the right mouse button is Window.event.button = 3

************************************************************

The Window.event object represents the state of the event, such as the element that triggered the object, the position and state of the mouse, the key pressed, and so on.
The Window.event object is only valid during the event.
Some of the properties of window.event are only meaningful for specific events. For example, the Fromelement and Toelement properties are only meaningful for onmouseover and onmouseout events.
If the mouse moves out of the window after the event is triggered, the value returned is-1, which is a read-only property. This means that you can only use it to get the current position of the mouse, but it cannot be used to change the position of the mouse.

the properties of the event object are
Altkey, Button, cancelbubble, ClientX, ClientY, Ctrlkey, Fromelement, KeyCode, OffsetX, OffsetY, PropertyName, Returnvalu E, ScreenX, ScreenY, Shiftkey, srcelement, Srcfilter, toelement, type, x, y

Here's a brief description of its properties
1.altKey
Description: Checks the state of the ALT key.
Syntax: Event.altkey
Possible values: When the ALT key is pressed, the value is TRUE, otherwise FALSE. Read-only.

2.button
Description: Check the mouse button that was pressed.
Syntax: Event.button
Possible values:
0 no keys, 1 left button, 2 press right, 3 press the left and the right, 4 press middle key, 5 press left and middle key, 6 press right and middle key, 7 press all keys
This property is only used for onmousedown, onmouseup, and onmousemove events. Returns 0 (for example, onclick) for other events, regardless of mouse state.

3.cancelBubble
Description: Detects whether to accept control over events of the upper element.
Syntax: event.cancelbubble[= cancelbubble]
Possible values: This is a read-write Boolean value
TRUE is not controlled by the upper primitive's events.
FALSE allows events to be controlled by the upper element. This is the default value.

4.clientX
Description: Returns the x-coordinate of the mouse in the window client area.
Syntax: Event.clientx
Note: This is a read-only property. This means that you can only use it to get the current position of the mouse, but it cannot be used to change the position of the mouse.

5.clientY
Description: Returns the y-coordinate of the mouse in the window client area.
Syntax: Event.clienty
Note: This is a read-only property. This means that you can only use it to get the current position of the mouse, but it cannot be used to change the position of the mouse.

6.ctrlKey
Description: Checks the state of the CTRL key.
Syntax: Event.ctrlkey
Possible values: When the CTRL key is pressed, the value is TRUE, otherwise FALSE. Read-only.

7.fromElement
Description: Detects onmouseover and onmouseout events that occur when the mouse leaves the element. Reference 18.toElement
Syntax: event.fromelement
Note: This is a read-only property.

8.keyCode
Description: Detects the internal code corresponding to the keyboard event. This property is used for onkeydown, onkeyup, and onkeypress events.
Syntax: event.keycode[= keycode]
Possible values: This is a read-write value, which can be any Unicode keyboard inside code. If no keyboard event is raised, the value is 0.

9.offsetX
Description: Checks the horizontal coordinates of the mouse position relative to the object that triggered the event.
Syntax: Event.offsetx

10.offsetY
Description: Check the vertical coordinates of the mouse position relative to the object that triggered the event
Syntax: event.offsety

11.propertyName
Description: Sets or returns the name of the property that changed the element.
Syntax: event.propertyname [= Sproperty]
Possible value: Sproperty is a string that specifies or returns the name of the property that has changed in the event of the element that triggered the event.
Note: This property is readable and writable. No default value. You can get the value of PropertyName by using the Onpropertychange event.

12.returnValue
Description: Sets or checks the value returned from the event
Syntax: event.returnvalue[= Boolean]
Possible values: The value in the true event is returned
False the default action for events on the source object is canceled

13.screenX
Description: Detects the horizontal position of the mouse relative to the user's screen
Syntax: Event.screenx
Note: This is a read-only property. This means that you can only use it to get the current position of the mouse, but it cannot be used to change the position of the mouse.

14.screenY
Description: Detects the vertical position of the mouse relative to the user's screen
Syntax: Event.screeny
Note: This is a read-only property. This means that you can only use it to get the current position of the mouse, but it cannot be used to change the position of the mouse.

15.shiftKey
Description: Checks the state of the SHIFT key.
Syntax: Event.shiftkey
Possible values: When the SHIFT key is pressed, the value is TRUE, otherwise FALSE. Read-only.

16.srcElement
Description: Returns the element that triggered the event. Read-only. See the beginning of this article for examples.
Syntax: event.srcelement

17.srcFilter
Description: Returns the filter that triggered the onfilterchange event. Read-only.
Syntax: Event.srcfilter

18.toElement
Description: Detects the elements that the mouse enters when the onmouseover and onmouseout events occur. Reference 7.fromElement
Syntax: event.toelement
Note: This is a read-only property.

19.type
Description: Returns the event name.
Syntax: Event.type
Note: Returns an event name that does not have "on" as the prefix, for example, the type returned by the OnClick event is click Read-only.

X. x
Description: Returns the x-coordinate of the mouse relative to the ancestor element with the Position property in the CSS property. If there is no ancestor element with the Position property in the CSS property, the BODY element is used as the reference object by default.
Syntax: event.x
Note: If the mouse moves out of the window after the event is triggered, the value returned is-1
This is a read-only property. This means that you can only use it to get the current position of the mouse, but it cannot be used to change the position of the mouse.

. Y
Description: Returns the y-coordinate of the mouse relative to the ancestor element with the Position property in the CSS property. If there is no ancestor element with the Position property in the CSS property, the BODY element is used as the reference object by default.
Syntax: EVENT.Y

This article link address: http://www.jb51.net/article/33525.htm

Description of the mouse click event in each browser and the event object properties

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.