JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Document.location Property

Name

Document.location Property---the URL of the current document

Availability

Navigator 2.0, Internet Explorer 3.0; deprecated in Navigator 3.0--use Document.URL instead

Synopsis

document.location

Description

In Navigator 2.0 and Internet Explorer 3.0, location is a read-only string property that contains the complete URL of the current document. The document.location property of a document is usually equal to the location.href of a window on these platforms. These two properties are not always equal, however, because the the location property of the Document object may be modified through URL redirection--Window.location contains the requested URL and Document.location specifies the actual URL of the retrieved document.

In Navigator 3.0, the location property of the Document object is a read-only reference to the same Location object referred to by the location property of the Window object. That is, in Navigator 3.0, window.location is always equal to document.location. Navigator 3.0 also introduces the URL property of the Document object. That new property behaves the same way as the location property did prior to Navigator 3.0--it is a string that contains the possibly redirected URL of the document.

While this is a fairly major change made in Navigator 3.0, it should not break many scripts. Because the Location object has a toString() method, the document.location property in Navigator 3.0 can be treated as if it were a string, just as it was in Navigator 2.0.

See Also

"Document", "Document.URL", "Window.location"


Previous Home Next
Document.links[] Book Index Document.open()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
Hosted by uCoz