Search

1/12/2009

window.location vs. document.location

document.location - MDC

Returns a Location object, which contains information about the URL of the document and provides methods for changing that URL. In Gecko browsers you can also assign to this property to load another URL.

document.location was originally a read-only property, although Gecko browsers allow you to assign to it as well. For cross-browser safety, use window.location instead.

To retrieve just the URL as a string, the read-only document.URL property can be used.

window.location - MDC


var locationObj = window.location;
window.location = newLocation;

where
* locationObj is an object of type Location, providing information about the current URL and methods to change it. Its properties and methods are described below.
* newLocation is a Location object or a string, specifying the URL to navigate to.

沒有留言: