HTML event attributes
Event attributes are special attributes that can be placed in various elements and can a trigger a segment of a script to be executed when certain actions occur such as the clicking of a mouse or putting focus on a textbox.
Window Events
Window events are events that are triggered when a page or frame is loaded or unloaded.
NOTE: Window events are only valid in the <body> and <frameset> tags.
| Attribute | Value | Description |
|---|---|---|
| onload | script_code | Will run a segment of a script when a page or frame is loaded |
| onunload | script_code | Will run a segment of a script when a page or frame is unloaded |
Form events
Form events are only valid in form elements.
| Attribute | Value | Description |
|---|---|---|
| onchange | script_code | Will run a segment of code when the data in a form element changes |
| onsubmit | script_code | Will run a segment of code when a form is submitted |
| onreset | script_code | Will run a segment of code when a form is reset |
| onselect | script_code | Will run a segment of code when a form element is selected |
| onblur | script_code | Will run a segment of code when a form element loses focus |
| onfocus | script_code | Will run a segment of code when a form element gets focus |
Keyboard Events
NOTE: Keyboard events are not valid in the <base>, <bdo>, <br>, <frame>, <frameset>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, <title> tags.
| Attribute | Value | Description |
|---|---|---|
| onkeydown | script_code | Will trigger a segment of code when a key is pressed |
| onkeyup | script_code | Will trigger a segment of code when a key is released |
| onkeypress | script_code | Will trigger a segment of code when a key is pressed AND released |
Mouse Events
NOTE: Mouse events are not valid in <base>, <bdo>, <br>, <frame>, <frameset>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, <title> tags.
| Attribute | Value | Description |
|---|---|---|
| onclick | script_code | Will trigger a segment of code when the mouse is clicked |
| ondblclick | script_code | Will trigger a segment of code when the mouse is double clicked |
| onmousedown | script_code | Will trigger a segment of code when the mouse button is pressed |
| onmousemove | script_code | Will trigger a segment of code when the mouse is moved |
| onmouseover | script_code | Will trigger a segment of code when the mouse moves over an element |
| onmouseout | script_code | Will trigger a segment of code when the mouse moves off an element |
| onmouseup | script_code | Will trigger a segment of code when the mouse button is released |




