| home / programming / javascript / professional / chap4 / 4 |
[next] |
|
Mainstream Browser Event ModelsWeb browsers were originally designed to display plain HTML and that was all. Handling of user input via HTML intrinsic events is a more recent innovation. Client-side languages like JavaScript came after HTML, and for earlier browsers it shows. It is only with advent of the 4.0 browsers that event handling mechanisms are organized in a general and flexible way. Microsoft and Netscape use different capitalization for event handler names. We're using the Netscape version here. Just convert to all-lowercase for the Microsoft equivalent. The Good Old Days That Weren't So GoodIn the simplest model for events, an event occurs, a handler fires and when it completes, then the event is over. Possibly the browser might do something afterwards. This is broadly how Netscape and Microsoft 3.0 browsers work. It's worth looking at these old browsers first, because the number of events in the version 4+ browsers are quite overwhelming. The events that appeared at the 3.0 level are the ones needed for the simplest and commonest scripting tasks, so they're a good place to start before diving in more deeply. Here is a list of those events:
These events, especially the ones that have to do with forms are very straightforward. If you have a modern browser, version 4.0+ then you can learn a great deal quite quickly just experimenting with these events. Try playing with this page:
However, even for the older version 3.0 browsers, the simple table shown is not really sufficient. This second table shows that for some events, more than one handler of the same type might fire:
For these browsers there is little you can do to control this behavior, except avoid using specific combinations of handlers. Chapter 7 on Forms and Data and Chapter 17 on Debugging collect some wisdom on how to manage these events. The Appendices list every event by object. If the situation is nontrivial for version 3.0 browsers, it follows that if more events or more features are added to the browser, something has to happen to give more control to the scriptwriter.
|
| home / programming / javascript / professional / chap4 / 4 |
[next] |
Created: April 4, 2001
Revised: April 4, 2001