JavaScript
applications are largely event driven. Events trigger JavaScript functions
to run. For example we can use the OnClick event of the form button
to trigger a pop up alert to appear when the user clicks on that object.
Event
handlers are embedded in documents as attributes of HTML as shown below.
<input
TYPE="button" VALUE="Click Me" ONCLICK="alert1()">
You can put any JavaScript statements inside the quotes following
OnClick. If you want to include more then one statement, separate statement
with a semicolon (;). Below are some examples of Event Handlers.
EVENT
APPLIES
TO
OCCURS
WHEN
onAbort
images
User
aborts the loading of an image
onBlur
windows,
frames and all form elements
User
removes input focus
onClick
buttons,
links, checkboxes,
User
clicks on form or element
onChange
text
fields, text areas, select lists
Users
changes the value of text
onFocus
windows,
frames, and all form elements
User
gives form element input focus
onLoad
document
body
User
loads the page
onMouseOver
areas,
links
User
moves the mouse pointer over a link or anchor