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.

Syntax:

object.URL;
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:
<head>
    <script type="text/javascript">
        function GetDocURL () {
            alert ("The URL of the document: " + document.URL);
        }
    </script>
</head>
<body>
    <button onclick="GetDocURL ();">Get the location of the document!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content