Example 1—Adding Last Modified Dates to Web Pages

Of the examples in this chapter, this one is probably the simplest and the one that needs the least code for accomplishing the effect.

Adding a last modified date to a Web page enables your visitors to know when the page last changed, which in turn helps them decide whether they want to read the page. It's a great example and really easy to use. Here it is in action:

<html>
<head>
<title>A Simple Page</title>
</head>
<body>
<script language = "JavaScript">
<!-- Cloaking device on!
document.write("Page last updated: " + document.lastModified)
// Cloaking device off -->
</script>
</body>
</html>

This example uses one method and one property of the document object. It uses the lastModified property ...

Get JavaScript™ 1.5 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.