Base hrefProperty
Base Object
Definition and Usage
The href attribute sets or returns the base URL for all links in a page.
Syntax
baseObject.href=URL
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the href attribute
Examples
Examples
The following example can return the base URL of the page:
<html>
<head>
<base id="htmldom" href="../jsref/index.html">
</head>
<body>
<p>Base URL is:
<script>
document.write(document.getElementById("htmldom").href);
</script>
</p>
</body>
</html>
<head>
<base id="htmldom" href="../jsref/index.html">
</head>
<body>
<p>Base URL is:
<script>
document.write(document.getElementById("htmldom").href);
</script>
</p>
</body>
</html>
The output of the above example:
Base URL is: https://www.example.com/jsref/
Try it Yourself »
Base Object Other Extensions