Export (0) Print
Expand All

initEvent method

Initializes a new generic event that the createEvent method created.

Document Object Model (DOM) Level 3 Events Specification, Section 4.1Internet Explorer 9

 

Syntax

object.initEvent(eventType, canBubble, cancelable)

Parameters

eventType [in]

Type: String

The event type.

canBubble [in]

Type: Boolean

true (true)

The event should propagate upward.

false (false)

The event does not propagate upward.

cancelable [in]

Type: Boolean

true (true)

The default action can be canceled.

false (false)

The default action cannot be canceled.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

Remarks

You can call the initEvent method only before the dispatchEvent method dispatches the event object. After the event is dispatched, its properties cannot be changed.

Examples

The following code example creates a custom event that bubbles but cannot be canceled.


var evt = document.createEvent("Event");
evt.initEvent("custom", true, false);
document.getElementById('target').dispatchEvent(evt); 

See also

BeforeUnloadEvent
CompositionEvent
CustomEvent
DragEvent
Event
FocusEvent
KeyboardEvent
MessageEvent
MouseEvent
MouseWheelEvent
MSSiteModeEvent
MutationEvent
StorageEvent
SVGZoomEvent
TextEvent
UIEvent
Reference
bubbles
cancelable
dispatchEvent

 

 

Show:
© 2014 Microsoft