Document.URL

The URL read-only property of the Document interface returns the document location as a string.

Syntax

var string = document.URL 

Example

JavaScript

document.getElementById("url").textContent = document.URL;

HTML

<p id="urlText">
  URL:<br/>
  <span id="url">URL goes here</span>
</p>

Result

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'Document.URL' in that specification.
Living Standard Defined that the property is a USVString instead of a DOMString.
Document Object Model (DOM) Level 1 Specification
The definition of 'Document.URL' in that specification.
Recommendation Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

See also

Document Tags and Contributors

 Last updated by: Sebastianz,