Document: URL property
The
URL read-only property of the Document
interface returns the document location as a string.
Value
A string containing the URL of the document.
Examples
JavaScript
js
document.getElementById("url").textContent = document.URL;
HTML
html
<p id="urlText">
URL:<br />
<span id="url">URL goes here</span>
</p>
Result
URL:
https://live.mdnplay.dev/en-US/docs/Web/API/Document/URL/runner.html?id=examples
https://live.mdnplay.dev/en-US/docs/Web/API/Document/URL/runner.html?id=examples
Specifications
| Specification |
|---|
| DOM Standard # ref-for-dom-document-url① |
Browser compatibility
Report problems with this compatibility data on GitHubChrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on iOS | Samsung Internet | WebView Android | |
|---|---|---|---|---|---|---|---|---|---|---|---|
Legend
Tip: you can click/tap on a cell for more information.
Full support
See also
- The
document.documentURIproperty which returns the same value.



