HTML and CSS Reference
In-Depth Information
Figure 10-17
calling a javascript function
function call
HTML code written to the Web page
function code
Parameter values can also themselves be variables. The following commands store
the library name in a text string variable named libText and call the showMsg() function
using that variable as the parameter value:
As a result, the following HTML code would be written to the Web document:
Functions can be called repeatedly with different parameter values to achieve different
results. For example, the following code calls the showMsg() function twice with differ-
ent parameter values to display two welcome paragraphs—one for the Monroe Public
Library and one for the Cutler Public Library:
You can call the showEM() function that you just entered to display the hypertext link
for Catherine Adler's e-mail address. The command is
As a result of this command, the userName parameter would contain a text string of
cadler and the emServer parameter would contain the text string . You're ready
to replace the commands you entered earlier to write the hypertext link for Catherine
Adler's e-mail address by calling the showEM() function.
To call the showEM() function:
1. Return to the mpl.htm file in your text editor and then scroll down the file to the
script element containing the JavaScript code for Catherine Adler's e-mail address.
2. Replace all of the commands within the script element with the following com-
mand, as shown in Figure 10-18:
Search WWH ::

Custom Search