Knowing which events can be associated with which objects is important.
It is much easier these days because the various browser are more consistent.
<img src='rose.gif' onclick='...some javascript..' />
Here is a list of some of the most common event handlers and the tags they apply to.
Event | Associated Objects | Comments |
onabort | images | occurs if user decides to stop downloading image |
onblur | windows, all form elements, frames | occurs when user clicks away from a form object |
onclick | buttons, radio buttons, checkboxes, submit buttons, reset buttons, links, images | very useful |
onchange | text fields, textareas, select lists | activates when a drop box element etc is clicked |
onfocus | windows, frames, all form elements | opposite to onblur() |
onload | window, body, images | Use this to invoke JavaScript after the page or an image has finished loading. <body onload="doit();"> very useful |
onmouseover | areas, links | Very commonly used. |
onmouseout | areas,links | Very commonly used. |
onreset | forms | Used when a reset button is clicked |
onselect | text fields, textareas | similar to onfocus, not used much |
onsubmit | form | can be used to check contents of a form |
onunload | body | often used to force a user to a related site - can be very irritating |
Here is a more Comprehensive List from w3schools.