The Base target Property in HTML DOM is used to set or return the value of the target attribute of a <base> element. The target attribute is used to specify the default target for all hyperlinks and forms in the page.
Syntax:
- It returns the Base target property.
baseObject.target
- It is used to set the Base target property.
baseObject.target = "_blank|_self|_parent|_top|framename"
Property Values:
- _blank: It is used to open a link in a new window.
- _self: It is used to open a link in the same frame.
- _parent: It is used to open a link in the parent frameset.
- _top: It open a link in the full body of the window.
- framename: It opens a link in the name dframe.
Return Value: It returns a string value which represents the default target for all hyperlink and forms in the page.
Example 1: This example returns the base target Property.
<!DOCTYPE html> <html> <head> <base id="Geek_Base" <title> HTML | DOM Base target Property </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>HTML | DOM Base target Property</h2> <button onclick="myGeeks()"> Click </button> <h4 id="Geek_p" style="color:green;font-size:24px;"></h4> <!-- Script to use DOM Base target Property --> <script> function myGeeks() { var x = document.getElementById("Geek_Base").target; document.getElementById("Geek_p").innerHTML = x; } </script> </body> </html> |
Output:
Before Clicking on Button:

After Clicking on Button:

Example 2: This example sets the base target Property.
<!DOCTYPE html> <html> <head> <base id="Geek_Base" href= <title> HTML | DOM Base target Property </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>HTML | DOM Base target Property</h2> <button onclick="myGeeks()"> Click </button> <h4 id="Geek_p" style="color:green;font-size:24px;"></h4> <!-- Script to use DOM Base target Property --> <script> function myGeeks() { var x = document.getElementById("Geek_Base").target = "_blank"; document.getElementById("Geek_p").innerHTML = "The value of the target attribute was " + "changed to " + x; } </script> </body> </html> |
Output:
Before Clicking on Button:

After Clicking on Button:

Supported Browsers: The browser supported by DOM base target property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | <base> target Attribute
- HTML | DOM Form target Property
- HTML | DOM Anchor target Property
- HTML | DOM Area target Property
- HTML | DOM target Event Property
- HTML | DOM Base href Property
- HTML | DOM Base Object
- JavaScript new.target meta Property
- HTML | <form> target Attribute
- HTML | <link> target Attribute
- HTML | <area> target Attribute
- HTML | <a> target Attribute
- HTML | target Attribute
- HTML | <base> href Attribute
- HTML | base Tag
- How to target desktop, tablet and mobile using Media Query ?
- CSS | :target Selector
- How to get relative click coordinates on the target element using JQuery?
- How to add target="_blank" to a link using jQuery ?
- How to target all Font Awesome icons and align them center?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


