HTML and CSS Reference
In-Depth Information
Plan
Ahead
Writing the date last modified on the Web page.
The date the Web page was last modified indicates how current the information is. When
writing this content, you should follow these guidelines:
Determine what your message will be. Many Web pages display a copyright notice
with the date last modified.
Create a <div> tag container with the id displayCopyRight.
Create a text message string enclosed in quotation marks and include the
document.lastModified property with the text string.
Use the innerHTML property to assign the message to the <div> tag container.
Displaying the Date the Document Was Last Modified
Most Web developers agree that a Web page should display the date the Web page
was last modified, so visitors are aware of how current the Web page content is. For the
Midwest Bridal Expo Web page, the date last modified should appear at the bottom of the
page in a smaller font to keep the message from distracting the user (see Figure 9-1 on
page HTML 411).
JavaScript provides an easy way to display the date by using the lastModified
property of the document object. The lastModified property displays the date in the form
of mm/dd/yyyy followed by the time in the form of hh:mm:ss. Table 9-25 shows the
general form of the lastModified property of the document.
The lastModified
Property
The lastModified property
may return different
values than expected
with older browsers and
unknown Web servers.
Table 9-25 lastModified Property
General form:
document.lastModified
Comment:
where lastModified is a property of the document object that returns the date the document
was last saved
Example:
var lastDateModified= document.lastModified
Table 9-26 shows the code to place the <div> tag container for the copyright and
the date last modified text.
Table 9-26 Code to Create the <div> Tag Container for the Copyright and Date Last Modified
Line
Code
<div id=“displayCopyRight”>
119
</div>
120
Table 9-27 shows the JavaScript code to create the user-defined function, copyRight(),
to display the date and time the document was last modified and a copyright message.
Table 9-27 Code to Display the lastModified Date
Line
Code
38
function copyRight() {
39
var lastModDate = document.lastModified
40
var lastModDate = lastModDate.substring(0,10)
41
displayCopyRight.innerHTML = “<p style='font-size:12pt; font-
family:helvetica;'>Today is “+weekDay+” “+monthDate+” “+year+”. We
have “+daysToBridalExpo+” days until the Midwest Bridal Expo.</p>”
42
}
 
Search WWH ::




Custom Search