This chapter describes the DOM Level 2 Event Model as implemented by Gecko. The event object itself is described, as well as the interfaces for event registration on other nodes in the DOM, event handers and event listeners, and several longer examples that show how the various event interfaces relate to one another.
DOM Event Interface
The DOM Event interface is exposed in the event objects that are passed to the event handlers on various elements in the DOM. The following very simple example shows how an event object can be referenced and manipulated from within one such event handler.
function foo(e) { // event handling functions like this one // get a reference to the event they handle // (in this case as "e"). alert(e); } table_el.onclick = foo;
This example is woefully simplistic, but it shows an important feature of events in the Gecko DOM, which is that event objects in the DOM are typically accessed in the event handler functions. Once you have a reference to the event object, you can access all of the properties and methods described in this chapter.
Also see Example 5: Event Propagation in the Examples chapter for a more detailed example of how events move through the DOM.
In addition to the event object described here, the Gecko DOM also provides methods for registering event listeners on nodes in the DOM, removing those event listeners, and dispatching events from the DOM. These and the various Event Handlers on HTML or XML elements are the main entry points for events in the DOM. These three methods are described in the DOM Element Reference chapter of this book.
Properties
Methods
Netscape Communications http://developer.netscape.com |