Javascript DOM HTML Document documentURI Property

Introduction

Get the location URI of the document:

var x = document.documentURI;

Click the button to display the location of this document.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from   www  .j a  v a  2 s. c om*/
  var x = document.documentURI;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

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

If the document was created by the DocumentImplementation object, or if it is undefined, the return value is null.

The documentURI property returns a String, representing the URI of the document




PreviousNext

Related