HTML and CSS Reference
The location object is a property of the window object and is used to access the URL of
the document currently loaded in the window. In previous examples, we have seen loca-
tion as a window property, but because it is really also an object itself, it also has proper-
ties used to describe the different parts of a URL (see Table 10.13).
If you are writing a page containing frames, the entire page might not be picked up
by a search engine, such as Yahoo! or Google. Anyone linking to your page via the search
engine will only get part of the page, not the complete frameset. Also, when a page is
divided into frames, the visitor cannot bookmark the page if the browser is not pointing
to the top frameset. The location object can be used to make sure the topmost window
is the one currently viewed in the browser. (See the section “Using the top Property to
Keep the Main Window Out of a Frame” on page 310.)
Table 10.13 Properties of the location Object
What It Describes in the URL
If it exists, the anchor part.
The entire URL.
The port number.
The protocol and colon.
The query string.