JavaScript

Tuesday April 8, 2025
updated: April 10, 2002

 
Home
Getting Started
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Resources
Credits

 

 


Lesson 6: EVENT HANDLERS

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
onReset forms user resets a form
onSelect text fields, text areas User selects form element's input field
onSubmit submit button User submits a form
onUnload document body User exits the page

back button
next button

© 2002 Tracy Johnson