THE LOCATION OBJECT
One of the most useful BOM objects is location, which provides information about the document that is currently loaded in the window, as well as general navigation functionality. The location object is unique in that it is a property of both window and document; both window.location and document.location point to the same object. Not only does location know about the currently loaded document, but it also parses the URL into discrete segments that can be accessed via a series of properties. These properties are enumerated in the following table (the location prefix is assumed).
If the browser was currently located at http://foouser:barpassword@www.wrox.com:80/WileyCDA/?q=javascript#contents, then the location object would behave as follows:
| PROPERTY NAME | RETURN VALUE | DESCRIPTION |
location.hash |
"#contents" |
The URL hash (the pound sign followed by zero or more characters), or an empty string if the URL doesn't have a hash. |
location.host |
“... |