Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Objects
 event Object

  Switch on low bandwidth view
event Object

Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.

Members Table

The following table lists the members exposed by the event object.

Attributes/Properties
Show:
AttributePropertyDescription
Abstract Gets the Abstract content of the entry banner in an Advanced Stream Redirector (ASX) file by using the event object.
altKey Retrieves a value that indicates the state of the ALT key.
altLeft Retrieves a value that indicates the state of the left ALT key.
Banner Gets the Banner content of an entry in an ASX file using the event object.
button Sets or retrieves the mouse button pressed by the user.
cancelBubble Sets or retrieves whether the current event should bubble up the hierarchy of event handlers.
clientX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
clientY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
constructor New for Windows Internet Explorer 8  Returns a references to the constructor of an object.
contentOverflow Retrieves a value that indicates whether the document contains additional content after processing the current LayoutRect object.
ctrlKey Sets or retrieves the state of the CTRL key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
data New for Internet Explorer 8  Sets or retrieves the body of the onmessage request.
dataFld Sets or retrieves the data column affected by the oncellchange event.
fromElementfromElement Sets or retrieves the object from which activation or the mouse pointer is exiting during the event.
keyCode Sets or retrieves the Unicode key code associated with the key that caused the event.
MoreInfo Gets the MoreInfo content of an entry banner in an ASX file through the event object.
nextPage Retrieves the position of the next page within a print template.
offsetX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the object firing the event.
offsetY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the object firing the event.
origin New for Internet Explorer 8  Sets or retrieves the scheme, hostname, and port of the document that fired the onmessage event.
propertyName Sets or retrieves the name of the property that changes on the object.
qualifier Sets or retrieves the name of the data member provided by a data source object.
reason Sets or retrieves the result of the data transfer for a data source object.
recordset Sets or retrieves from a data source object a reference to the default record set.
repeat Retrieves whether the onkeydown event is being repeated.
returnValue Sets or retrieves the return value from the event.
saveType Retrieves the clipboard type when oncontentsave fires.
screenX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the user's screen.
screenY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the user's screen.
shiftKey Retrieves the state of the SHIFT key.
shiftLeft Retrieves the state of the left SHIFT key.
source New for Internet Explorer 8  Retrieves the source window object of the onmessage event.
srcElement Sets or retrieves the object that fired the event.
srcFilter Sets or retrieves the filter object that caused the onfilterchange event to fire.
srcUrn Retrieves the Uniform Resource Name (URN) of the behavior that fired the event.
toElement Sets or retrieves a reference to the object toward which the user is moving the mouse pointer.
type Sets or retrieves the event name from the event object.
url New for Internet Explorer 8  Sets or retrieves the fully qualified URL of the document that fired the event.
userName Retrieves the sFriendlyName parameter that is passed to the useService method.
wheelDelta Retrieves the distance and direction the wheel button has rolled.
x Sets or retrieves the x-coordinate (in pixels) of the mouse pointer's offset from the closest relatively positioned parent element of the element that fired the event.
y Sets or retrieves the y-coordinate (in pixels) of the mouse pointer's offset from the closest relatively positioned parent element of the element that fired the event.
CollectionDescription
bookmarks Returns a collection of Microsoft ActiveX Data Objects (ADO) bookmarks tied to the rows affected by the current event.
boundElements Returns a collection of all elements on the page bound to a data set.
ObjectDescription
dataTransfer Provides access to predefined clipboard formats for use in drag-and-drop operations.
ObjectDescription
Event Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the Event Constructor prototype chain.

Remarks

The event object is available only during an event—that is, you can use it in event handlers but not in other code.

Although all event properties are available to all event objects, some properties might not have meaningful values during some events. For example, the fromElement and toElement properties are meaningful only when processing the onmouseover and onmouseout events.

In Microsoft Visual Basic Scripting Edition (VBScript), you must access the event object through the window object.

Several of the properties that apply to this object are not writable unless this object has been created using the createEventObject method. The following is a list of these properties: altKey, altLeft, button, clientX, clientY, ctrlKey, ctrlLeft, dataFld, offsetX, offsetY, propertyName, qualifier, reason, repeat, screenX, screenY, shiftKey, shiftLeft, srcUrn, type, x, and y.

Examples

This example uses the event object to check whether the user clicked the mouse within a link, and to prevent the link from being navigated if the SHIFT key is down.

<HTML>
<HEAD><TITLE>Cancels Links</TITLE>
<SCRIPT LANGUAGE="JScript">
function cancelLink() {
    if (window.event.srcElement.tagName == "A" && window.event.shiftKey) 
        window.event.returnValue = false;
}
</SCRIPT>
<BODY onclick="cancelLink()">

This example displays the current mouse position in the browser's status window.

<BODY onmousemove="window.status = 'X=' +  window.event.x + ' Y=' 
    + window.event.y">

Standards Information

This object is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 2 World Wide Web link.

Applies To

window
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
How can I pass javascript objects to client-side code?      Antaris ... Thomas Lee   |   Edit   |   Show History

Well, I know the mechanics of passing it, but it presents itself as a System.__ComObject.

If I am passing the event object, how could i access the properties of this object?

unclear - extent - event effect      Mr. Raymond Kenneth Petry ... Thomas Lee   |   Edit   |   Show History

The following is-not a method for invoking Ctrl-F-find-on-page via JScript:

eg.

var eventSubj=document.createEventObject();
eventSubj.ctrlKey=true;
eventSubj.keyCode=70;
elementId.fireEvent('onkeydown',eventSubj);




// likewise 'onkeypress'; keyCode=6; which appears to be too late to invoke Ctrl-F-find-on-page.
suggestion - add existing properties      Mr. Raymond Kenneth Petry   |   Edit   |   Show History

Suggestion: Include event properties: event.menu, that contextmenu can be used in keyed position, eg. for Cursoring down a popup menu (in lieu of mouse) ... event.Windows....

Ray.

Remark - readonly      Mr. Raymond Kenneth Petry ... Thomas Lee   |   Edit   |   Show History
The event object is not writable, though many properties are ... which in case of popups, must be switched to the popup-event object.
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker