Event attributes in Javascript)

Source: Internet
Author: User

Original article: http://www.cnblogs.com/coolicer/archive/2010/10/04/1842653.html

Attribute

1. altKey Description: checks the status of the alt key.
Syntax: event. altKey
Possible value: When the alt key is pressed, the value is TRUE; otherwise, the value is FALSE. Read-only.

2. button Description: Check the pressed mouse key.
Syntax: event. button
Possible values: 0 No keys, 1 left-click, 2 right-click, 3 right-click, 4 right-click, 5 right-click, and 6 Right-click, and 7 Right-click all keys
This attribute is only used for onmousedown, onmouseup, and onmousemove events. For other events, 0 (such as onclick) is returned regardless of the mouse status ).

3. cancelBubble Description: checks whether the event control of upper-layer elements is accepted.
Syntax: event. cancelBubble [= cancelBubble]
Possible value: This is a read/write Boolean value:
TRUE is not controlled by the event of the parent layer. FALSE allows the event to be controlled by the upper-layer element. This is the default value.
Example: The following code snippet demonstrates that when you click onclick on an image, if the shift key is also pressed at the same time, the upper layer element (body) is canceled) the showSrc () function triggered by the event onclick on.

 

4. clientX Description: returns the X coordinates of the mouse in the client area of the window.
Syntax: event. clientX
Note: This is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.

5. clientY Description: return the Y coordinate of the mouse in the client area of the window.
Syntax: event. clientY
Note: This is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.

6. ctrlKey Description: Check the ctrl key status.
Syntax: event. ctrlKey
Possible value: When the ctrl key is pressed, the value is TRUE; otherwise, the value is FALSE. Read-only.

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

8. keyCode Description: Check the internal code corresponding to the keyboard event. This attribute is used for onkeydown, onkeyup, and onkeypress events.
Syntax: event. keyCode [= keyCode]

Possible value: This is a readable value and can be any Unicode keyboard internal code. If no keyboard event is triggered, the value is 0.

9. offsetx Description: checks the horizontal coordinates of the mouse position relative to the trigger event object.
Syntax: event. offsetx

10. offsety Description: checks the vertical coordinates of the mouse position relative to the trigger event object.
Syntax: event. offsety

11. propertyname Description: set or return the name of the changed attribute of the element.
Syntax: event. propertyname [= sproperty]
Possible value: sproperty is a string that specifies or returns the name of the attribute changed by the element that triggers the event. This attribute can be read and written. No default value.
Note: You can use the onpropertychange event to obtain the value of propertyname.

12. returnvalue Description: set or check the value returned from the event
Syntax: event. returnvalue [= Boolean]
Possible value: the value in the true event is returned. The default operation of the event on the false source object is canceled.
For examples, see the beginning of this article.

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 attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it 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 attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.

15. shiftkey Description: checks the status of the shift key.
Syntax: event. shiftkey
Possible value: when the shift key is pressed, the value is true; otherwise, the value is false. Read-only.

16. srcelement Description: return the element of the trigger event. Read-only. For examples, see the beginning of this article.
Syntax: event. srcelement

17. srcfilter Description: return the filter that triggers the onfilterchange event. Read-only.
Syntax: event. srcfilter

18. toelement Description: 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 attribute.

19. type description: name of the returned event.
Syntax: event. Type
Note: The name of an event without the "on" prefix is returned. For example, the type returned by the onclick event is click read-only.

20. x Description: returns the x axis coordinate of the upper-level element of the position attribute relative to the css attribute. If there is no upper-level element with the position attribute in the css attribute, the BODY element is used as the reference object by default.
Syntax: event. x
Note: If the mouse moves out of the window after an event is triggered, the returned value is-1, which is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.

21. y Description: returns the y axis coordinate of the upper-level element of the position attribute relative to the css attribute. If there is no upper-level element with the position attribute in the css attribute, the BODY element is used as the reference object by default.
Syntax: event. y
Note: If the mouse moves out of the window after an event is triggered, the returned value is-1, which is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.

Related Article

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.