The ability to trigger actions in the browser by HTML events is New to HTML 4.0, like executing a JavaScript when a user clicks on an HTML element.
Here is a list of attributes that define event actions. these attributes can be inserted into HTML tags
A D V E R T I S E M E N T
Window Events
These are valid only in body and frameset elements
Attribute
Value
Description
onload
script
Script to be run when a document loads
onunload
script
Script to be run when a document unloads
Form Element Events
These are valid only in form elements.
Attribute
Value
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 focus
onfocus
script
Script to be run when the element gets focus
Keyboard Events
Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param,
script, style, and title elements.
Attribute
Value
Description
onkeydown
script
What to do when key is pressed
onkeypress
script
What to do when key is pressed and released
onkeyup
script
What to do when key is released
Mouse Events
These are not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param,
script, style, and title elements.
Attribute
Value
Description
onclick
script
Action will be taken on mouse click
ondblclick
script
Action will be taken on doubleclicking the mouse
onmousedown
script
Action to be performed when mouse button is pressed
onmousemove
script
Action to be performed when mouse pointer moves
onmouseover
script
Action to be performed when mouse pointer moves over an element
onmouseout
script
What to do when mouse pointer moves out of an element
onmouseup
script
What function to carry when mouse button is released