THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Anchor target Property

Anchor Object Reference Anchor Object

Example

Change the target of a link to "_blank" (the link will be opened in a new window):

document.getElementById("myAnchor").target = "_blank";
Try it yourself »

Definition and Usage

The target property sets or returns the value of the target attribute of a link.

The target attribute specifies where to open the linked document.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The target property is supported in all major browsers.


Syntax

Return the target property:

anchorObject.target

Set the target property:

anchorObject.target="blank|_self|_parent|_top|framename"

Property Values

Value Description
_blank Opens the linked document in a new window
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frameset
_top Opens the linked document in the full body of the window
framename Opens the linked document in a named frame

Technical Details

Return Value: A String, representing where to open the linked document

More Examples

Example

Return the value of the target attribute of a link:

var x = document.getElementById("myAnchor").target;

The result of x will be:

_self
Try it yourself »

Related Pages

HTML reference: HTML <a> target attribute


Anchor Object Reference Anchor Object