Get Base Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Base

Introduction

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>
<html>
<head>
  <base id="myBase" href="https://www.java2s.com/jsref/">
</head>//ww  w.j  a  v a  2s . c om
<body>

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

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

<script>
function myFunction() {
    var x = document.getElementById("myBase").href;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials