Skip to Content
JavaScript: The Definitive Guide, Fourth Edition
book

JavaScript: The Definitive Guide, Fourth Edition

by David Flanagan
November 2001
Intermediate to advanced
936 pages
68h 43m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, Fourth Edition

Document Information Properties

Several properties of the Document object provide information about the document as a whole. For example, the following code shows how you can use the lastModified, title, and URL properties to include an automatic timestamp within a document. This feature allows users to judge how up-to-date (or out-of-date) a document is, and it can also be useful information when a document is printed.

<hr><font size="1">
Document: <i><script>document.write(document.title);</script></i><br>
URL: <i><script>document.write(document.URL);</script></i><br>
Last Update: <i><script>document.write(document.lastModified);</script></i>
</font>

referrer is another interesting property: it contains the URL of the document from which the user linked to the current document. One possible use is to save this value in a hidden field of a form on your web page. When the user submits the form (for whatever reason your page contains the form in the first place), you can save the referrer data on the server so you can analyze the links that refer to your page and track the percentage of hits that come through various links. Another use of this property is a trick to prevent unauthorized links to your page from working correctly. For example, suppose you want to allow other sites to link only to the top-level page on your site. You can use the referrer property in conjunction with the location property of the Window object to redirect any links from outside the site to the top-level ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

John Pollock
JavaScript Cookbook, 3rd Edition

JavaScript Cookbook, 3rd Edition

Adam D. Scott, Matthew MacDonald, Shelley Powers

Publisher Resources

ISBN: 0596000480Supplemental ContentCatalog PageErrata