The Browser Object Model
window.document
This particular object is rather unique in that it contains both the Document Object Model and also some Browser Object Model fields. As this tutorial series is about the BOM we will look exclusively at those fields that are a part of the Browser Object Model.
There are four of these fields which most browsers support and which may have some use.
- window.document.url contains the address of the current page and is a place where you can read the path and filename of the current page from. By updating the field you can also redirect the browser to the specified URL.
- window.document.lastModified provided that the date/time is actually passed from the server will display when the page was last modified.
- window.document.referrer reads the referrer header of the page which (provided that your visitor does not have a privacy option turned on) will contain the last page that your visitor was on before coming to the current page.
Of these three values, the first is the only one that will always contain a meaningful value (but window.location provides a more powerful version of the same functionality), the second will either always or never contain a value depending on how your hosting is configured, and the third may or may not contain a value depending on whether individual visitors allow it. Because of this the third of these values is almost useless and its use is best avoided - a better alternative if you need to know what page someone came from and it is on your site is to pass a copy of the addresses between the pages yourself so that you know that the value will be passed regardless of your visitor's privacy settings. In the case of lastModified you should probably be asking yourself why you need to tell your visitor when your page was last updated. It is more common now to not provide that information in your web page and to allow your visitors to make the call themselves from their browser address bar if they need to find out when you last updated the page.
There are a number of other BOM fields attached to window.document but they all reference fields which are either deprecated or which are better accessed via the standard DOM commands.
In view of this your best option in almost all cases is to forget about the window.document BOM commands and use only the window.document DOM commands.

