Document URL Property - Javascript DOM

Javascript examples for DOM:Document URL

Description

The URL property returns the full URL of the current HTML document.

Return Value

A String, representing the entire URL of the document, including the protocol (like http://)

The following code shows how to get the full URL of the current HTML document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p>Click the button to display the URL of the document.</p>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from   w  w w . ja va 2 s. c  om*/
    var x = document.URL;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials