initEvent method
Initializes a new generic event that the IDocumentEvent::createEvent method created.
![]() ![]() |
Syntax
HRESULT retVal = object.initEvent(eventType, canBubble, cancelable);
Parameters
- eventType [in]
-
Type: BSTR
The event IDOMEvent::type.
- canBubble [in]
-
Type: VARIANT_BOOL
- cancelable [in]
-
Type: VARIANT_BOOL
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 IDOMEvent::initEvent method only before the IEventTarget::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
Show:

