Anchor target Property

❮ 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 »

Description

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

Property
target Yes Yes Yes Yes Yes

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;
Try it Yourself »

Related Pages

HTML reference: HTML <a> target attribute


❮ Anchor Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.