Javascript Reference - HTML DOM documentURI Property








The documentURI property sets or gets the location of a document.

Browser Support

documentURI Yes No Yes Yes Yes

Syntax

Set the documentURI:

document.documentURI=locationURI

Return the documentURI:

var v = document.documentURI

Return Value

A String type value representing the URI of the document.





Example

The following code shows how to get the location URI of the document.


<!DOCTYPE html>
<html>
<body>
<p id="demo">test</p>
<button onclick="myFunction()">test</button>
<!--   w  ww  .ja  va 2  s  .  c om-->
<script>
function myFunction()
{
    var x=document.getElementById("demo");
    x.innerHTML=document.documentURI;
}
</script>
</body>
</html>

The code above is rendered as follows: