New to HTML 4.0 is the ability to let HTML events trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element. Below is a list of attributes that can be inserted into HTML tags to define event actions.
Only valid in body and frameset
| Attributes: | Values: | Description: |
|---|---|---|
| onload | script | Script to be run when a document loads |
| onunload | script | Script to be run when a document unloads |
Only valid in form elements.
| Attributes: | Values: | Description: |
|---|---|---|
| onchange | script | Script to be run when the element changes |
| onsubmit | script | Script to be run when the form is submitted |
| onreset | script | Script to be run when the form is reset |
| onselect | script | Script to be run when the element is selected |
| onblur | script | Script to be run when the element loses its focus |
| onfocus | script | Script to be run when the element is focused |
Not valid in: base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, title.
| Attributes: | Values: | Description: |
|---|---|---|
| onkeydown | script | When a keyboard key is on its way down |
| onkeypress | script | When a keyboard key is pressed |
| onkeyup | script | When a keyboard key is released |
Not valid in: base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, title.
| Attributes: | Values: | Description: |
|---|---|---|
| onclick | script | What to do on a mouse click |
| ondblclick | script | What to do on a mouse double-click |
| onmousedown | script | What to do when mouse button is pressed |
| onmousemove | script | What to do when mouse pointer moves |
| onmouseout | script | What to do when mouse pointer moves out of an element |
| onmouseover | script | What to do when mouse pointer moves over an element |
| onmouseup | script | What to do when mouse button is released |