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

Initialize the event object prior to dispatching it.


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


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');
document.getElementById('foo').dispatchEvent( evt );