Javascript event object

Source: Internet
Author: User
Javascript event object

The javascript event object is used to describe JavaScript events. It mainly applies to various browser versions later than ie4 and nn4. Event indicates the event status, such as the event element, keyboard status, mouse position, and mouse button status. Once an event occurs, an event object is generated. If you click a button, the corresponding event object is generated in the browser memory.

References to events by IE

In ie4 or later versions, the event object is accessed as the window property: window. envent. The referenced window part is optional. Therefore, the script treats the event object like a global reference:

Event. propertyname

Evnet object member table:

The following table lists the members of the event object. Click the label on the left to select the member type you want to view.

Object
Datatransfer provides access to the predefined clipboard format for use in the drag operation.

Set
Bookmarks returns the ActiveX & reg; Data Object (ADO) bookmarks bound to the row affected by the current event.
Boundelements returns a set of all elements bound to a given dataset.

Attribute
Abstract: Use the event object to obtain the abstract content of the project banner in the advanced Stream Redirector (ASX) file.
Altkey sets or obtains the status of the Alt key.
Altleft sets or obtains the status of the Left Alt key.
Banner uses the event object to obtain the banner content of the item in the advanced Stream Redirector (ASX) file.
Click to set or obtain the mouse button that the user presses.
Cancelbubble sets or obtains whether the current event needs to bubble up In the event handle.
Clientx sets or obtains the X coordinates of the mouse pointer position relative to the client area of the window. The client area does not include the control and scroll bar of the window.
Clienty sets or obtains the Y coordinate of the mouse pointer position relative to the client area of the window. The client area does not include the control and scroll bar of the window.
The retrieval of contentoverflow indicates whether the document contains additional content after processing the current layoutrect object.
Ctrlkey sets or obtains the status of the ctrl key.
Ctrlleft sets or obtains the status of the Left ctrl key.
Dataworks sets or obtains the data columns affected by the oncellchange event.
Fromelement sets or gets the object that is activated when an event occurs or the mouse is about to exit.
Set or obtain the Unicode key code associated with the buttons that cause the event.
Moreinfo obtains the moreinfo content of the project banner in the advanced Stream Redirector (ASX) file through the event object.
Obtain the position of the next page in the print template from nextpage.
Offsetx is used to set or obtain the X coordinate between the cursor position and the object that triggers the event.
Offsety is used to set or obtain the Y coordinate of the object relative to the trigger event.
Propertyname: set or obtain the property name that has been changed on the object.
Qualifier sets or gets the name of the data member provided by the data source object.
Reason sets or obtains the data transmission result of the data source object.
Recordset sets data source objects or obtains references to default datasets.
Repeat checks whether the onkeydown event is repeated.
Returnvalue is used to set or obtain the return value of an event.
Savetype obtains the clipboard type when oncontentsave is triggered.
Screenx is used to set or obtain the X coordinates of the cursor position relative to the user's screen.
Screeny is used to set or obtain the Y coordinate of the mouse pointer position relative to the user's screen.
Shiftkey sets or obtains the status of the shift key.
Shiftleft sets or obtains the status of the Left Shift key.
Srcelement sets or gets the object that triggers the event.
Srcfilter sets or gets the filter object that triggers the onfilterchange event.
Srcurn obtains the unified Resource Name (URN) for triggering event behavior ).
Set or retrieve the reference of the object to which the user wants to move the mouse pointer.
Type obtains the event name from the event object.
Wheeldelta sets or gets the scroll distance and direction of the scroll wheel button.
X sets or obtains the X-pixel coordinates of the cursor position relative to the parent document.
Y sets or obtains the Y pixel coordinate of the cursor position relative to the parent document.

Note

The event object is only available in the event -- this means that you can use this object in the event handle, but not in other code.

Although all event attributes can be accessed through all event objects, some attributes may be meaningless in some events. For example, the fromelement and toelement attributes make sense only when processing onmouseover and onmouseout events.

In Microsoft Visual Basic & reg; script version (VBScript), you must access the event object through the window object.

This object is available in Microsoft & reg; Internet Explorer 4.0 scripts.

Example

In the following example, the event object is used to determine whether the user clicks on the link or not, and the link is not navigated when the shift key is pressed.

<HTML>
<Head> <title> cancel link </title>
<Script language = "jscript">
Function cancellink (){
If (window. event. srcelement. tagname = "A" & window. event. shiftkey)
Window. event. returnvalue = false;
}
</SCRIPT>
<Body onclick = "cancellink ()">

To enable all attributes or methods of the event object, select ie5.5 or later.

 

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.