All about Events
JavaScript’s interaction with HTML is handled througheventsthat 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 moving 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.
When Netscape released its source code into the open source community under the name Mozilla,a key aim of the developers was to adhere to as many of the standards as possible.When there were gaps in the standards,the Mozilla group looked at working drafts of the standards to fill them.Because of this, Mozilla’s event model closely follows the DOM standards.Latecomers Opera and Safari have also recently embraced the DOM standard event model, leaving Internet Explorer as the main browser without proper support for the DOM event model.But even with different DOM implementations between browsers,some basic characteristics remain the same.
|