HTML DOM baseURI Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM baseURI property returns the base Uniform Resource Identifier (URI) of the document. The property is read-only. The return type is a string value that represents the base URI of the given page.

Syntax

Following is the syntax for baseURI Property −

node.baseURI

Example

Let us see an example of the HTML DOM baseURI Property −

<!DOCTYPE html>
<html>
<body>
<p>Click the button below to see the base URI of the document</p>
<button onclick="BaseFunction()">BASE URI</button>
<p id="Sample"></p>
<script>
   function BaseFunction() {
      var x = document.baseURI;
      document.getElementById("Sample").innerHTML = x;
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking the BASE URI button −

In the above example −

We have created a button BASE URI to execute the BaseFunction() −

<button onclick="BaseFunction()">BASE URI</button>

The BaseFunction() gets the baseURI of the document using the baseURI property and displays it into the paragraph with id “Sample” −

function BaseFunction() {
   var x = document.baseURI;
   document.getElementById("Sample").innerHTML = x;
}
raja
Updated on 06-Aug-2019 14:26:15

Advertisements