Event Handlers
Well, they kind of do what the name implies: they handle events that take place during the execution of a Web page or JS code. Events like what the user does with his/her mouse. They usually work in conjunction with HTML forms, which provide for text boxes, text areas, radio buttons, checkboxes, and other input graphics like that. (You've probably all seen them; go to amazon.com to see a bunch of these things, or any other site which sells goods online.) Some of these event handlers are interactive, which means that they can be applied to events initiated by the user; others are non-interactive, which means they execute when the page loads or unloads--not when the user directly does something like click or move a mouse.
There are four parts to handling events (even though our text only lists three):
Here's a list of JS event handlers, and the HTML form graphics to which they apply.
Event Handler | HTML form object to which it applies |
onAbort | image |
onBlur | select, text, text area |
onChange | select, text, text area |
onClick | button, checkbox, radio, link, reset, submit, area |
onError | image |
onFocus | select, text, textarea |
onLoad | window, image |
onMouseOver | link, area |
onMouseOut | link, area |
onReset | form |
onSelect | text, textarea |
onSubmit | form |
onUnload | window |
onMouseOver and onMouseOut are often used for some cool graphic effects, like loading and unloading an image when you slide your mouse over a Web page. onClick and onChange are some of the most commonly used event handlers, because this is how you would load user input from an HTML form into your JS code.