Anchor target Property
Anchor Object
Definition and Usage
The target property can set or return the value of the target attribute.
The target attribute describes where to open the link.
Syntax
Set the target attribute:
anchorObject.target="
value
"
Return the target attribute:
anchorObject.target
| Value | Description |
|---|---|
| _blank | Loads the document in a new, unnamed window. |
| _self | Loads the target document in the same frame or window. |
| _parent | Loads the document into the parent window or the frameset containing the frame that holds the hyperlink reference. |
| _top | Loads the document into the window containing the hyperlink, replacing any frames currently displayed in the window. |
| framename | Loads the document in the same frame. |
Browser support





All major browsers support the target property.
Example
Example
Change the target of a link:
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Runoob Tutorial(runoob.com)
title
<
script
function changeTarget(){ document.getElementById('runoob').target="_blank"; }
script
head
<body>
<a id="runoob" href="//www.runoob.com">Visit the Runoob Tutorial
a
<br>
<br>
<input type="button" onclick="changeTarget()" value=">Modify the target
"
<
p
Try clicking the link before you click the button.
p
body
html
Try it »
Anchor Object