Topic_12_CIS423_JavaScript_Functions
Topic_12_CIS423_JavaScript_Functions
JavaScript: Functions
These dialogs are valid ways to receive input from a user and
to display messages, but they’re fairly limited in their
capabilities.
A prompt dialog can obtain only one value at a time from
the user, and a message dialog can display only one
message.
©1992-2012 by Pearson Education, Inc.
All Rights Reserved.
9.5.2 Displaying Random
Images
User Interactions Via Event Handling
Inputs are typically received from the user via an HTML5 form
Outputs are typically displayed to the user in the web page.
This program uses an HTML5 form and a new graphical user
interface concept—GUI event handling.
The JavaScript executes in response to the user’s interaction
with an element in a form. This interaction causes an event.
Scripts are often used to respond to user initiated events.
element.addEventListener(event, function, useCapture);
window.addEventListener("load", loadFunction);
function loadFunction() { alert("All page’s elements loaded"); }
©1992-2012 by Pearson Education, Inc.
All Rights Reserved.
9.5.2 Displaying Random
Images
The body Element
The elements in the body are used extensively in the script.
Loading a Document
Many examples will execute a JavaScript function when the
event.
To specify the function to call when an event occurs, you