Base href Property - Change the value of the base URL: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Base

Description

Base href Property - Change the value of the base URL:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<base id="myBase" href="/jsref/">
</head>/*from   ww w  . jav  a  2  s . com*/
<body>

<a href="default.asp">Default</a>

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
    document.getElementById("myBase").href = "/html/";
    document.getElementById("demo").innerHTML = "Base URL was changed from /jsref/ to /html/.";
}
</script>

</body>
</html>

Related Tutorials