Availability
JavaScript 1.0
Synopsis
document.lastModifiedDescription
lastModified is
a read-only string property that contains
the date and time at which document was
most recently modified. This data is derived from HTTP header data
sent by the web server. The web server generally obtains the
last-modified date by examining the modification date of the file
itself.
Web servers are not required to provide last-modified dates for the
documents they serve. When a web server does not provide a
last-modified date, JavaScript assumes 0, which translates to a date
of midnight, January 1, 1970, GMT. The following example shows how
you can test for this case.
Example
It is a good idea to let readers know how recent the information you
provide on the Web is. You can include an automatic timestamp in your
documents by placing the following script at the end of each HTML
file. Doing this means you do not need to update the modification
time by hand each time you make a change to the file. Note that this
script tests that the supplied date is valid before displaying it:
<script>
if (Date.parse(document.lastModified) != 0)
document.write('<p><hr><small><i>Last modified: '
+ document.lastModified
+ '</i></small>');
</script>
See Also
The Document location,
referrer, and title properties
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.