Anchor target attribute
Definition and usage
target
Attribute sets or returns the link's target attribute Value.
target
Attribute specifies the location where the linked document is opened.
See also:
HTML Reference Manual:HTML <a> target Attribute
Example
Example 1
Change the target of the link to "_blank" (the link will open in a new window):
document.getElementById("myAnchor").target = "_blank";
Example 2
Return the target attribute value of the link:
var x = document.getElementById("myAnchor").target;
Syntax
Return the target attribute:
anchorObject.target
Set the target attribute:
anchorObject.target = "_blank|_self|_parent|_top|framename"
Attribute value
Value | Description |
---|---|
_blank | Open the document linked in a new window. |
_self | Open the linked document in the same frame when clicked (default). |
_parent | Open the linked document in the parent frame set. |
_top | Open the linked document in the entire window. |
framename | Open the linked document in the named frame. |
Technical Details
Return Value: | A string value indicating the location where the linked document is to be opened. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |