MutationEvent.initMutationEvent() (Method)

After creating a MutationEvent object, it must be initialized with this method call.


DOM level - 2
JavaScript - 1.5
Netscape - 6.0
JavaScript syntax:NmyMutationEvent.initMutationEvent(aType, aBubble, aCancel, aNode, aPrev, aNew, aName)
Argument list:aTypeA string containing the event type
aBubbleA boolean value indicating whether the event can bubble
aCancelA boolean value indicating whether the event can be cancelled
aNodeA reference to a related Node object
aPrevA string containing the previous value
aNewA string containing the new value
aNameA string containing the name of an attribute

A new event object is manufactured by calling the DocumentEvent.createEvent() method. That event should have been defined with a type specified as "MutationEvent". If it was, then it will support an initMutationEvent() method. This must be called before the event is dispatched otherwise the event object will not contain enough information for the event dispatcher/handler to make sense of it and route it to the correct target objects.

Two boolean argument values define whether the event will be allowed to be cancelled and what type of propagation to use (bubble or capture).

You can add a reference to a related node and can also define previous and new values if you are simulating an attribute change. Finally for an attribute change, the attribute name can be specified.

See, EventTarget object, Node object