This is an event handler function which you can define in the script source text and can then register as the listener for an event by means of the addEventListener() and removeEventListener() methods belonging to the EventTarget object.
The script function takes a single argument which is an Event object that is instantiated as the event is triggered.
If you copy a document node with the cloneNode() method, the copies will not inherit the same listeners and you will need to add new listeners to handle any events that are dispatched to the new copies of the nodes.
HTML 4.0 describes a way to associate listeners with objects as they are instantiated by means of the HTML tag attributes. However, to support multiple listeners, the internal mechanisms no longer use the member attribute mechanism for associating listeners with targets. This means that code that assigns values to the onEventHandler property family, may no longer work as expected if you mix old and new style event handling techniques. Newer versions of browsers may deprecate the old way and may in subsequent versions render it unsupported.
The DOM level 2 event model is somewhat ambiguous about this part of the event handling complex. It describes an event listener as having a handleEvent() method which is called. It is not clear how you would add a handleEvent() method as a member of a function object which was itself the element that was registered to receive the event.
There may be changes to this aspect of the event model in later DOM levels to better support HTML based event specification.
Prev | Home | Next |
EventException.code | Up | EventTarget object |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |