Get the baseURI of the document:
var x = document.baseURI;
Click the button to display the base URI of the document.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//w w w . j a v a 2 s . co m var x = document.baseURI; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The baseURI property returns the base URI of the HTML document.
This property is read-only.