You are here: Reference > JavaScript > client-side > HTML DOM > properties > URL (document, XMLDocument)

URL property (document, XMLDocument)

Browser support:
Specifies or returns the location of the current document.
This property is equivalent to the location.href property.


You can find the related objects in the Supported by objects section below.
This property is read/write.

Possible values:

String that represents the URL of the document.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the URL property:
    <script type="text/javascript">
        function GetDocURL () {
            alert ("The URL of the document: " + document.URL);
    <button onclick="GetDocURL ();">Get the location of the document!</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content