HTML - DOM Document baseURI Property



HTML DOM document baseURI property used to return the base Uniform Resource Identifier (URI) of the document. The property is read-only.

Syntax

document.baseURI;

Return Value

It returns a string which represents absolute base URL of the document containing the node.

Example of HTML DOM Document baseURI Property

In the following example we will returns the URI of the page using baseURI property.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Document baseURI Property
    </title>
</head>
<body>
    <button onclick="fun()">Click Me</button>
    <p id="URI"></p>
    <script>
        function fun(){
            let x=document.baseURI
            document.getElementById("URI").innerHTML= 
            "Base URI of the Page: " + x;
        }
    </script>
</body>
</html>

Supported Browsers

Property Chrome Edge Firefox Safari Opera
baseURI Yes 1 Yes 12 Yes 1 Yes 4 Yes 12.1
html_dom.htm
Advertisements