Event
Summary
Represents an event.
Properties
- bubbles
- Gets a value that indicates whether an event propagates up from the event target.
- cancelable
- Gets a value that indicates whether you can cancel an event’s default action.
- currentTarget
- Gets the event target that is currently being processed.
- defaultPrevented
- Gets whether the default action should be canceled.
- eventPhase
- Gets the event phase that is being evaluated.
- isTrusted
- Gets a value that indicates whether a trusted event source created an event.
- target
- Gets the element that is the original target of the event.
- timeStamp
- Gets the time, in milliseconds, when an event occurred.
- type
- Gets the name of an event.
Methods
- initEvent
- Initializes a new generic event that the createEvent method created.
- preventDefault
- Cancels the default action of an event, if possible.
- stopImmediatePropagation
- Prevents any further propagation of an event.
- stopPropagation
- Prevents propagation of an event beyond the current target.
Events
bounce
:
change
:
copy
:
- cut
- Fires after a data selection is cut to the clipboard.
- dataavailable
- Fires when new data at a data source becomes available.
- datasetchanged
- Fires when content at a data source has changed.
- datasetcomplete
- Fires when data transfer from the data source has completed.
- deactivate
- Sets an active version of an object to not active.
- error
- Fires when an error occurs.
- errorupdate
- Executes any error handling associated with the event.
finish
:
Examples
This example uses addEventListener to listen to the load event in order to change the title of the page to indicate that the page is done loading. It uses isTrusted to make sure the event was triggered by the user agent itself and not by some script.
function initialize(e) {
if (e.isTrusted) {
document.title = "The page is done loading.";
}
}
window.addEventListener("load", initialize, false);
This example uses addEventListener to listen to the keydown event and suppress key down operations using the preventDefault method of the Event instance object. This causes any key presses that occurs within text fields not to emit text into the fields.
function suppressPresses(e) {
e.preventDefault();
}
document.addEventListener("keydown", suppressPresses, false);
Related specifications
- DOM Level 3 Events
- Working Draft
See also
Related pages
- BeforeUnloadEventBeforeUnloadEvent
- CompositionEventCompositionEvent
- CustomEventCustomEvent
- DragEventDragEvent
- FocusEventFocusEvent
- KeyboardEventKeyboardEvent
- MessageEventMessageEvent
- MouseEventMouseEvent
- MouseWheelEventMouseWheelEvent
- MutationEventMutationEvent
- StorageEventStorageEvent
- TextEventTextEvent
- UIEventUIEvent
- WheelEventWheelEvent
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]