Table of contentsAppendices |
1.5 Event listener registrationEvent listener registrationNOTE: There are mainly two ways to associate an event listener to a node in the tree:
Using the EventTarget methods[top]Using theEventTarget methods
The user can attach an event listener using the methods on the
myCircle.addEventListenerNS("http://www.w3.org/2001/xml-events",
"DOMActivate",
myListener,
true,
myEvtGroup);
The methods do not provide the ability to register the same event listener more than once for the same event type and the same phase. The target phase and the bubbling phase are coupled during the registration, i.e. it is not possible to register an event listener for only one of these two phases (but the listener itself could ignore events during one of these phases if desired). It is also not possible to register an event listener for a specific event target and have it only triggered for this event target during the bubbling or capture phases (but again, the listener itself could ignore events with other event targets if desired).
To register an event listener, DOM applications must use the
methods
An Using XML Events[top]Using XML EventsIn [XMLEvents], event listeners are attached using elements and attributes: <listener event="DOMActivate" observer="myCircle" handler="#myListener"
phase="capture" propagate="stop"/>
Event listeners can only be registered on Using XML or HTML attributes[top]Using XML or HTML attributesIn languages such as [HTML40], [XHTML10], or [SVG1], event listeners are specified as attributes: <circle id="myCircle" onactivate="myListener(evt)"
cx="300" cy="225" r="100" fill="red"/>
Since only one attribute with the same name can appear on an
element, it is therefore not possible to register more than one
event listener on a single
In order to achieve compatibility with those languages,
implementors may view the setting of attributes which represent
event handlers as the creation and registration of an |