Document: URL property - Web APIs | MDN

archived 15 Jan 2024 18:50:42 UTC

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

#Specifications

Specification
DOM Standard
# ref-for-dom-document-url①

#Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
URL

Legend

Tip: you can click/tap on a cell for more information.
Full supportFull support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

#See also

0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%