element in the HTML page.
The concept and use of events in client-side activity is critical for most applications. An HTML or browser event is something that triggers a script or a module into action. Typically, some user interaction with the browser or document triggers an event, although in some situations, the browser itself might be the source for the event. The event handler parameter defines the name of the function that will handle the event when it is fired. Not all elements in an HTML document receive all events. A summary of common events and handler function names, taken from the "Netscape Java Script Guide," is given in Table 3-1.
|Event||Applies to||Occurs When||Event Handler|
|Abort||Images||User aborts the loading of an image, by, for example, clicking a link or the Stop button.||onAbort|
|Blur||Windows, frames, and all form elements||User removes input focus from window, frame, or form element.||onBlur|
|Click||Buttons, radio buttons, check boxes, Submit buttons, Reset buttons, links||User clicks form element or link.||onClick|
|Change||Text fields, text areas, select lists||User changes value of element.||onChange|
|Error||Images, windows||The loading of a document or image causes an error.||onError|
|Focus||Windows, frames, and all form elements||User gives input focus to window, frame, or form element.||onFocus|
|Load||Document body||User loads the page in the Navigator.||onLoad|
|Mouse out||Areas, links||User moves mouse pointer out of an areaclient-side image mapor link.||onMouseout|
|Mouse over||Links||User moves mouse pointer over a link.||onMouseOver|
|Reset||Forms||User resets a form: clicks a Reset button.||onReset|
|Select||Text fields, text areas||User selects form element's input field.||onSelect|
|Submit||Submit button||User submits a form.||onSubmit|
|Unload||Document body||User exits the page.||onUnload|
tag of an HTML document defines the main textual content of the document and can generate the following events:
Generally, these events are fired when the content is created and destroyed and when it receives and loses user focus. The main controller function would probably handle the Load event of the
tag. In the following HTML example, the onLoad event handler is assigned to the main() function. When the event is fired, the main() function is executed. This function overwrites the original content of the page. The result is a Web page that displays the text "I am in control now, ha ha ha!" instead of "This is the normal content."
This is the normal content.
Overview of Modeling and Web-Related Technologies
Building Web Applications