Javascript examples for DOM HTML Element:Base
You can create a <base> element by using the document.createElement() method:
<!DOCTYPE html> <html> <head> </head>/*from w w w . j a v a 2 s .co m*/ <body> <button onclick="myFunction()">create a BASE element</button> <p id="demo"></p> <script> function myFunction() { var x = document.createElement("BASE"); x.setAttribute("href", "https://www.java2s.com"); document.head.appendChild(x); document.getElementById("demo").innerHTML = "created a BASE element in the HEAD section"; } </script> </body> </html>