HTML and CSS Reference
In-Depth Information
Line 38 defines the copyRight() function. Line 39 assigns the date the Web page
was last modified and assigns it to a temporary variable, lastModDate. Line 40 uses the
substring() method to extract the date portion only. Line 41 uses the innerHTML prop-
erty to assign the message string to the <div> tag container. The document.URL displays
the Web address of this document. Line 42 closes the function.
To Include the Date Last Modified and a Copyright Message in a Text String
The following steps enter JavaScript code to include the date last modified and a copyright message in a
text string.
Scroll down and click
line 119.
Enter the JavaScript
code In Table 9-26.
Do not press the
e n t e r key after the
last line.
division <div> tag with
id attribute for copyright
and date last modified
do not press ENTER after
the closing </div> tag
Figure 9-11
Scroll up and click
line 38.
JavaScript code to extract the date
last modified and display only the
first 10 characters of the date in
the format of (mm/dd/yyyy)
Enter the JavaScript
code shown in
Table 9-27.
Press the
e n t e r key
after each line, and
press the e n t e r key
twice after the } in
line 42 (Figure 9-12).
concatenated string message
assigned to id attribute of
<div> tag to display message
at bottom of Web page
Figure 9-12
Completing the JavaScript Section
As you know, all HTML tags must have start and end tags to separate them from
other page elements. To complete this section of JavaScript code, it is necessary to add the
end comment tag and the end </script> tag.
Search WWH ::

Custom Search