HTML DOM Anchor target property
Definition and Usage
target property sets or returns the target property value.
target attribute describes where to open the link.
grammar
Set target property:
anchorObject.target="value"
Returns target properties:
anchorObject.target
value | description |
---|---|
_blank | Load the document in a new unnamed window |
_self | Loading the destination document in the same frame or window |
_parent | Loading the document contains the parent window or frameset hyperlink reference framework |
_top | Loading the document window that contains the hyperlink, replace any frame currently being displayed in the window |
framename | Load the document in the same frame frame |
Browser Support
All major browsers support target attribute
Examples
Examples
Change a link target:
<html>
<head>
<script>
function changeTarget()
{
document.getElementById('w3s').target="_blank";
}
</script>
</head>
<body>
<a id="w3s" href="http://www.w3cschool.cc">W3CSchool</a>
<input type="button" onclick="changeTarget()" value="Change target">
</body>
</html>
<head>
<script>
function changeTarget()
{
document.getElementById('w3s').target="_blank";
}
</script>
</head>
<body>
<a id="w3s" href="http://www.w3cschool.cc">W3CSchool</a>
<input type="button" onclick="changeTarget()" value="Change target">
</body>
</html>
try it"
Anchor objects