myEvent.initEvent( eventTypeArg, canBubbleArg, cancelableArg ) in DOM Level 2 Events

Initialize the event object prior to dispatching it.

Arguments

nametypedescription
eventTypeArg String Specifies the event type. This
canBubbleArg Boolean Specifies whether or not the e
cancelableArg Boolean Specifies whether or not the e
Return Type
(none)

Description

The initEvent method is used to initialize the value of an Event created through the DocumentEvent interface. (See DocumentEvent.createEvent(...).) This method may only be called before the Event has been dispatched via the dispatchEvent(...) method, though it may be called multiple times during that phase if necessary. If called multiple times the final invocation takes precedence. If called from a subclass of Event interface only the values specified in the initEvent method are modified, all other attributes are left unchanged.

var evt = document.createEvent('HTMLEvents');
evt.initEvent('change',true,true);
document.getElementById('foo').dispatchEvent( evt );