Javascript examples for DOM HTML Element:Base
The target property sets or gets the target attribute in a base element, which controls the default target for all hyperlinks and forms in the page.
Set the target property with the following Values
Value | Description |
---|---|
_blank | Open links in a new window |
_self | Open links in the same frame as it was clicked (this is default) |
_parent | Open links in the parent frameset |
_top | Open links in the full body of the window |
framename | Open links in a named frame |
A String, representing the default target for all hyperlinks and forms in the page
The following code shows how to return the base target for all links on a page:
<!DOCTYPE html> <html> <head> <base id="myBase" href="https://www.java2s.com/jsref/"> </head>/* ww w. j ava 2s.c om*/ <body> <p><a href="https://www.java2s.com/">java2s.com</a></p> <p><a href="https://www.java2s.com/">java2s.com</a></p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var v = document.getElementById("myBase").target; document.getElementById("demo").innerHTML = v; } </script> </body> </html>