HTML and CSS Reference
In-Depth Information
code for additional call to
user-defined function with
onLoad event handler
Press the
s p a c e b a r , type
to add the call to the
popUpNotice() user-
defined function to
the left of the second
quotation mark, but
do not press the e n t e r
key (Figure 10-36).
Is this the only way to open a pop-up window?
An open() method can be placed anywhere in the <script> section in the <head> section. Once the
<head> section loads in the browser, it will execute the “stand-alone” open() method, opening a
pop-up window. The code must be in the <head> section, however, for this to work properly.
do not press
e n t e r key at end
of statement
Figure 10-36
Adding Copyright and the Date Last Modified
As you learned in Chapter 9, the purpose of displaying the date a Web page was last
modified is to make sure the user knows how current the information is contained on the
Web page. You added JavaScript code to the Midwest Bridal Expo Web page to display
the URL, a copyright notice, and the date the file was last modified. The Shoreline State
Bank Web page should include similar JavaScript code to display just the date the Web
page was modified, not the time.
To display the footer message of the copyright and date the Web page was last
modified, you need to insert a <div> tag at the bottom of the Web page. Table 10-30
shows the code for creating the <div> tag container. The embedded style for the
displayDateLast id attribute will size the division to 50% of the screen width and
place the division in the center of the screen.
Table 10-30 Code to Create a <div> Tag Container
<div id="displayDateLast">
To display just the date, the code in Table 10-31 uses the substring() method to grab
just the date and display copyright information.
Table 10-31 Code to Display the Date Last Modified Using the substring() Method
function copyRight() {
var lastModDate = document.lastModified
var lastModDate = lastModDate.substring(0,10)
displayDateLast.innerHTML = "<h6>Copyright &copy; Shoreline State Bank"+"<br />
This document was last modified "+lastModDate+".</h6>"
Line 105 declares the copyRight() user-defined function. Line 106 assigns the date
last modified from the document lastModified property. The substring(0,10) method in
line 107 extracts the first 10 characters of the date and time — mm/dd/yyyy — so only
the date is displayed, not the time. Line 108 assigns the message string to the <div> tag
container using the id attribute, displayDateLast, and the innerHTML property. The text is
formatted with the <h6> tag and the <br /> tag places the information on two separate lines.
Search WWH ::

Custom Search