EventTarget.dispatchEvent() (Method)

Create and send an event trigger to a target node.

Availability:

DOM level - 2
JavaScript - 1.5
Netscape - 6.0
Property/method value type:Boolean primitive
JavaScript syntax:NmyEventTarget.dispatchEvent(anEvent)
Argument list:anEventA reference to an Event object

Events can be created by your script independently of any other kind of event triggering. Indeed, they can be triggered using this mechanism from within the event handling complex because the event mechanisms specified by DOM level 2 must be re-entrant. That means they may be called recursively without any cross coupling of the local storage between nested or concurrent handlers.

Events triggered by this mechanism are handled in the same way as implementation generated events.

You must first create an Event object to pass as an argument to this method when you call it. The resulting Boolean value tells you whether the preventDefault flag was set by any of the listeners that were invoked. If this value is true, then any default behavior should be suppressed. It is quite important to provide a consistent level of support for this so that it behaves in the same way as an implementation controlled event dispatcher.

During the handling of the event being dispatched by this method, an EventException may be raised.

At DOM level 2, only the unspecified event type is available as an exception. This will be raised by an unspecified or null event type value.

See also:EventException object