# Document: location property



The read-only **`location`** property of the [Document](https://developer.mozilla.org/en-US/docs/Web/API/Document) interface returns a [Location](https://developer.mozilla.org/en-US/docs/Web/API/Location) object, which contains information about the URL of the document and provides methods for changing that URL and loading another URL.

To retrieve just the URL as a string, the read-only [document.URL](https://developer.mozilla.org/en-US/docs/Web/API/document/URL)
property can also be used.

## Value

A [Location](https://developer.mozilla.org/en-US/docs/Web/API/Location) object. If the current document is not in a browsing context, the returned value is
`null`.

Although the `location` property itself is read-only in the sense that you can't replace the `Location` object, you can still assign to the `location` property directly, which is equivalent to assigning to its [href](https://developer.mozilla.org/en-US/docs/Web/API/Location%2Fhref) property. You can also modify the `Location` object using the [assign()](https://developer.mozilla.org/en-US/docs/Web/API/Location%2Fassign) and [replace()](https://developer.mozilla.org/en-US/docs/Web/API/Location%2Freplace) methods.

## Examples

```js
console.log(document.location);
// Prints a Location object to the console
```

## Specifications

## Browser compatibility

## See also

- The interface of the returned value, [Location](https://developer.mozilla.org/en-US/docs/Web/API/Location)
- A similar information, but attached to the [browsing context](https://developer.mozilla.org/en-US/docs/Glossary/browsing%20context),
  [Window.location](https://developer.mozilla.org/en-US/docs/Web/API/Window/location)
