|
|
 |
onUnload event handler
onunload executes JavaScript
immediately after someone leaves the page. A common use (though not
that great) is to thank someone as that person leaves your page for coming
and visiting.
<body onunload="alert('Thank you. Please come back to this site and visit us soon, ok?')">
There are other event handlers, many belonging to forms.
These event handlers are discussed in the tutorial
Accessing and validating forms using Javascript.
Here is a list of commonly used event handlers in
JavaScript:
| Event Handlers |
|
Applicable inside: |
| onAbort |
|
<img> tags |
| onBlur |
|
window object, all form objects (ie: <input>), and <frame>. |
| onClick |
|
Most visible elements such as <a>, <div>, <body> etc. |
| onChange |
|
Use this to invoke JavaScript if the mouse goes pass some link |
| onError |
|
Text fields, textareas, and select lists. |
| onFocus |
|
Most visible elements such as <a>, <div>, <body> etc. |
| onLoad |
|
<body>, <img>, and <frame> |
| onMouseover |
|
Most visible elements such as <a>, <div>, <body> etc. |
| onMouseout |
|
Most visible elements such as <a>, <div>, <body> etc. |
| onReset |
|
<form> tag, triggered when the form is reset via <input
type="reset">. |
| onSelect |
|
Elements with textual content. Most commonly used inside text fields
and textareas. |
| onSubmit |
|
<form> tag, triggered when the form is submitted. |
| onUnload |
|
<body> |
|