Section 25.90. Element.addEventListener( ): register an event handler


25.90. Element.addEventListener( ): register an event handler

DOM Level 2 Events:

25.90.1. Synopsis

 void addEventListener(String type,                       Function listener,                       boolean useCapture); 

25.90.1.1. Arguments

type

The type of event for which the event listener is to be invoked. For example, "load", "click", or "mousedown".


listener

The event-listener function that is invoked when an event of the specified type is dispatched to this element. When invoked, this listener function is passed an Event object and is invoked as a method of the element on which it is registered.


useCapture

If true, the specified listener is to be invoked only during the capturing phase of event propagation. The more common value of false means that the listener is not invoked during the capturing phase but instead is invoked when this node is the actual event target or when the event bubbles up to this node from its original target.

25.90.2. Description

This method adds the specified event-listener function to the set of listeners registered on this node to handle events of the specified type. If useCapture is true, the listener is registered as a capturing event listener. If useCapture is false, it is registered as a normal event listener.

addEventListener( ) may be called multiple times to register multiple event handlers for the same type of event on the same node. Note, however, that the DOM makes no guarantees about the order in which multiple event handlers are invoked.

If the same event-listener function is registered twice on the same node with the same type and useCapture arguments, the second registration is simply ignored. If a new event listener is registered on this node while an event is being handled at this node, the new event listener is not invoked for that event.

When a node is duplicated with Node.cloneNode( ) or Document.importNode( ), the event listeners registered for the original node are not copied.

This method is also defined by, and works analogously on, the Document and Window objects.

25.90.3. See Also

Event; Chapter 17




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net