HTML and CSS Reference
In-Depth Information
3. Below the script element, insert another script element that contains statements
to do the following:
a. Insert a multiline comment containing the following text:
b. Declare a variable named timestr equal to the value returned from the
showDateTime() function.
c. Declare a variable named mapnum equal to the value returned from the get-
Map() function.
4. Scroll down the file to the div element with id value maps and replace the line
with a script element that writes the following HTML code:
where mapNum is the value of the mapNum variable.
5. Scroll down a few lines and replace the date/time value January 1, 2014, 12:00 a.m.
with a script element that writes the value of the timeStr variable to the Web page.
6. Save your changes to the file and then open skymap.htm in your Web browser. Verify
that the planisphere displays the current date and time.
7. If you're able to modify the date/time settings on your computer, change the date and
time and then reload or refresh the page to verify that the date/time value changes
and that the map also changes. Debug your code as necessary.
8. Submit your completed files to your instructor.
Use JavaScript to
display random
banner ads.
Case Problem 2
Data Files needed for the case problem: ad1.jpg - ad5.jpg, ads.js, fp.jpg, fronttxt.htm,
logo.jpg, modernizr-1.5.js, random.js, styles.css
Ridgewood Herald Tribune Maria Ramirez manages advertising accounts for the
Ridgewood Herald Tribune in Ridgewood, New Jersey. To offset the cost of the paper's
Web site, Maria is selling ad space on the company's home page. She is looking at cre-
ating banner ads to be displayed on the paper's masthead, with each ad linked to the
advertiser's Web site. Because ad space on the paper's home page is the most valuable,
Maria has decided to sell space to five companies, with the selection of the banner ad
determined randomly each time a user opens the page.
Maria has asked for your help in writing the JavaScript code to display banner ads ran-
domly. She has provided a collection of functions that will be useful to you.
• The randInt() function returns random integers from 1 to n. To call the randInt() func-
tion, use the following expression:
• The adDescription() function returns the description of the n th ad from a list of ad
descriptions. To call the function, use the following expression:
• The adLink() function returns the URL of the n th ad of the collection. To call the func-
tion, use the following expression:
Search WWH ::

Custom Search