Common Properties and methods for event objects
The event object is used to represent the current event, which has many states, such as the position of the mouse click, the key when the keyboard is pressed, the HTML element in which the event occurred, whether the default action is performed, whether it is bubbling, and so on, all of which exist as properties and methods of the event object. To obtain a corresponding state, you must access the corresponding properties and methods.
Common Properties and methods for event objects (specifications)
| Properties |
Description |
IE |
Non-IE |
| the
| Altkey |
Returns whether "ALT" is pressed when the event is triggered. |
Yes |
Yes |
Yes |
| button |
Returns which mouse button is clicked when the event is triggered. |
Yes |
Yes |
Yes |
| ClientX |
Returns the horizontal coordinates of the mouse pointer when the event is triggered. |
Yes |
Yes |
Yes |
| ClientY |
Returns the vertical coordinate of the mouse pointer when the event is triggered. |
Yes |
Yes |
Yes |
| Ctrlkey |
Returns whether the "CTRL" key is pressed when the event is triggered. |
Yes |
Yes |
Yes |
| Metakey |
Returns whether the "meta" key is pressed when the event is triggered. |
No |
Yes |
Yes |
| Relatedtarget |
Returns the node associated with the target node of the event. |
No |
Yes |
Yes |
| ScreenX |
Returns the horizontal coordinates of the mouse pointer when an event is triggered. |
Yes |
Yes |
Yes |
| ScreenY |
Returns the vertical coordinate of the mouse pointer when an event is triggered. |
Yes |
Yes |
Yes |
| Shiftkey |
Returns whether the "SHIFT" key is pressed when the event is triggered. |
Yes |
Yes |
Yes |
| Bubbles |
Returns a Boolean value that indicates whether the event is a bubbling event type. |
No |
Yes |
Yes |
| Cancelable |
Returns a Boolean value that indicates whether the event can hold a default action that can be canceled. |
No |
Yes |
Yes |
| Currenttarget |
Returns the element whose event listener triggered the event. |
No |
Yes |
Yes |
| Eventphase |
Returns the current stage of event propagation. |
|
|
Yes |
| Target |
Returns the element that triggered this event (the target node of the event). |
No |
Yes |
Yes |
| TimeStamp |
Returns the date and time the event was generated. |
No |
Yes |
Yes |
| Type |
Returns the name of the event represented by the current event object. |
Yes |
Yes |
Yes |
| Method |
Description |
IE |
Non-IE |
| the
| Initevent () |
Initializes the properties of the newly created Event object. |
No |
Yes |
Yes |
| Preventdefault () |
Notifies the browser not to perform the default action associated with the event. |
No |
Yes |
Yes |
| Stoppropagation () |
No more events are being dispatched. |
No |
Yes |
Yes |
In addition to the properties and methods specified in the above-mentioned specifications, IE browser supports the following properties.
properties of the event object (ie specific)
| Properties |
Description |
| Cancelbubble |
This property must be set to TRUE if the event handle wants to prevent the event from propagating to the containment object. |
| Fromelement |
For mouseover and Mouseout events, fromelement references the element that is moved out of the mouse. |
| KeyCode |
For the KeyPress event, this property declares the Unicode character code generated by the key being struck. For the KeyDown and KeyUp events, it specifies the virtual keyboard code of the key being tapped. The virtual keyboard code may be related to the layout of the keyboard you are using. |
| Offsetx,offsety |
The x-coordinate and y-coordinate of the location of the event that occurred in the coordinate system of the event source element. |
| ReturnValue |
If this property is set, its value is higher than the return value of the event handle. By setting this property to Fasle, you can cancel the default action of the source element where the event occurred. |
| Srcelement |
A reference to the Window object, Document object, or Element object that generated the event. |
| Toelement |
For mouseover and Mouseout events, this property refers to the element that is moved into the mouse. |
| X, y |
The X-and y-coordinates of the location where the event occurred, relative to the most inner containment element that is dynamically positioned with CSS.
|
JS Event Attribute Method list