Javascript examples for DOM HTML Element:Base
Base href Property - Change the value of the base URL:
<!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>