Get Base Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Base


The Base object represents an HTML <base> element.

You can access a <base> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
  <base id="myBase" href="">
</head>//ww  w.j  a  v a  2s . c om

<button onclick="myFunction()">get the URL of the base element</button>

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

function myFunction() {
    var x = document.getElementById("myBase").href;
    document.getElementById("demo").innerHTML = x;


Related Tutorials