EVENTS
Every object on your page has certain 'Events' which can trigger your JavaScript functions. For example, we use the onClick event of the form button to indicate that a function will run when the user clicks that object. We define the events in the same HTML tag which we use to place an object on the screen. So a button which runs myFunction() when clicked will be written this way.
<input type=button value="click me" onClick="myFunction()">
I could also use onMouseOver to make an event happen when the user's mouse is over certain objects. For instance a message could appear in an alert box.
Images can't have events, but links can. So I added an onMouseOver event to the above image by creating a link to nothing around it. Here is the code for the above image:
<A HREF="#" OnMouseOver="alert('hi')">
<IMG SRC="http://images.webteacher.com/javascript/images/pointme.gif" BORDER=0>
</A>
The following table outlines all of the event handlers in NetScape version 3.0
| Event | Applies to | Occurs when | Event handler |
|---|---|---|---|
| abort | images | User aborts the loading of an image (for example by clicking a link or clicking 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, checkboxes, submit buttons, reset buttons, links | User aborts the loading of an image (for) | onClick |
| change | text fields, textareas, select list | 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 |
| mouseout | areas, links | User moves mouse pointer out of an area (client-side image map) or link | onMouseOut |
| mouseover | links | User moves mouse pointer over a link | onMouseOver |
| reset | forms | User resets a form (clicks a Reset button) | onReset |
| select | text fields, textareas | User selects form element' | onSelect |
| submit | submit button | User submits a form | onSubmit |
| unload | document body | User exits the page | onUnload |