HTML and CSS Reference
In-Depth Information
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
The lastModified property
may return different
values than expected
with older browsers and
unknown Web servers.
Table 9-25 lastModified Property
General form:
where lastModified is a property of the document object that returns the date the document
was last saved
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
<div id=“displayCopyRight”>
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
function copyRight() {
var lastModDate = document.lastModified
var lastModDate = lastModDate.substring(0,10)
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>”
Search WWH ::

Custom Search