The DOM level 2 event model has been designed to be platform and language neutral. The standard describes bindings for Java and ECMAScript and it is applicable to other environments too.
The foundation on which DOM Events are constructed requires that DOM Core and DOM views are available too.
There are three main types of events:
User interface related events such as those triggered by an input device. A key press or mouse click is an example.
Logical events that may have been triggered via the UI but are more abstract. A focus change or element notification event is an example.
Mutation events which are caused by some action that modified the structure of the document.
Events are captured in several ways depending on the implementation and context. For example, server side events would be captured in a different way to those in a web browser.
In a structured document, a target element that receives an event may handle it or may choose to pass it upwards through the document hierarchy to its parent node. This is called event bubbling and was first provided in a web browser by MSIE. As of version 6, the same event model is used in Netscape which attempts to implement the entire DOM level 2 event capabilities as described in the standard.
Events can be cancelled. This can prevent them from bubbling upwards or from exercising some default behavior.
As an alternative to implementing an event bubbling technique, the DOM level 2 event model also provides for an event capturing approach where the highest ancestor object that registers a listener will receive the event before the target object. This traverses the document hierarchy from top to bottom and is the opposite of the bubbling technique which traverses from bottom to top.
EventTarget objects are not really objects in their own right although it is convenient to describe them thus in the DOM specification. An EventTarget is actually one of the already existing classes but when the DOM level 2 event model is implemented, the element objects that can react to events become EventTargets by inheriting the properties and methods of the EventTarget class as well as any others they inherit from their superclass.
Events are handled by registering EventListener functions. These are registered by the potential EventTargets. An EventTarget is simply an HTML instantiated object, or one that has been manufactured by script and placed into the display for the user to interact with.
See also: | Element object, Event, Event management, Event model, MutationEvent object |
Prev | Home | Next |
DOM - Level 3 | Up | Domain error |
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. |