Main Page

All about Events

All about Events
JavaScript’s interaction with HTML is handled through
events
that occur when the user or browser
manipulates a page. When the page loads, that’s an event. When the user clicks a button, that
click, too, is an event. Developers can use these events to execute coded responses, which cause
buttons to close windows, messages to be displayed to users, data to be validated, and virtually
any other type of response imaginable to occur.
When events first appeared in browsers (IE 3.0 and Netscape Navigator 3.0), they focused on mov-
ing some server functionality to the client. At that time, the standard method for accessing the
Internet was through a dial-up connection and modem. With speeds topping out at 56 kbps, each
trip to the server could turn into minutes of down time.
JavaScript is designed to solve this problem by allowing such functionality to take place on the
client, saving a trip to the server. As such, most of the early events centered on the use of forms
and form elements, where simple validation could be more efficiently carried out. Through the
years and browser versions, events continued to grow to support more of the page.
Events Today
As discussed earlier, events are a part of the Document Object Model (DOM). Unfortunately, as
also discussed previously, no events are defined in DOM Level 1 and only in a subset in DOM
Level 2. The full development of events occurred in DOM Level 3, which was finalized in 2004.
With few standards to guide them early on, browsers developers were left to invent their own
event models. Internet Explorer first created and implemented its own event model in version 4.0
(circa 1995) and hasn’t altered it significantly since that time. Of course, no DOM standards existed
at that point, which means Internet Explorer still uses what can be considered a proprietary event
model. Some of its design, however, was eventually folded in the DOM.
12_579088 ch09.qxd 3/28/05 11:39 AM Page 261


JavaScript EditorFree JavaScript Editor     Ajax Editor


©