HTML and CSS Reference
In-Depth Information
The
random.js
file contains the randInt() function. The
ads.js
file contains the adDescription()
and adLink() functions. Figure 10-38 shows a preview of the completed Web page with one
of the random banner ads displayed at the top of the page.
Figure 10-38
Ridgewood Herald tribune rotating ads
Complete the following:
1. Use your text editor to open the
fronttxt.htm
file from the tutorial.10\case2 folder
included with your Data Files. Enter
your name
and
the date
in the comment sec-
tion of the file. Save the file as
front.htm
in the same folder.
2. After the
link
element in the head section, insert a
script
element accessing the
functions in the
random.js
ile.
3. Insert another
script
element accessing the functions in the
ads.js
ile.
4. Scroll down the file to the
div
element with the id
ads
. Replace the content of the
div element with a
script
element containing the following statements:
a. Declare a variable named
rNumber
equal to the value returned from the
randInt()
function using
5
as the parameter value. Append the following comment to the
statement:
generateƒaƒrandomƒintegerƒfromƒ1ƒtoƒ5
b. Declare a variable named
rAd
equal to the text string returned from the
adDescription()
function using
rNumber
as the parameter value. Append the
following comment to the statement:
descriptionƒofƒtheƒrandomƒad
c. Declare a variable named
rLink
equal to the URL returned from the
adLink()
function using
rNumber
as the parameter value. Append the following comment:
URLƒofƒtheƒrandomƒadƒ