You are here: Reference > JavaScript > client-side > HTML DOM > properties > target (a, area, base, form, link)

target property (a, area, base, form, link)

Browser support:
Specifies or returns the target window or frame where the document is to be opened.

You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: target

Possible values:

String that identifies the target window.
One of the following values:
Indicates a new window.
Indicates the HTML content area of the Media Bar.
Indicates the parent frame.
Indicates the browser search panel.
Default. Indicates the frame containing the source link.
Indicates the topmost window.
Target name
The name of the target window or frame (frame or iframe). If there is no window or frame with the specified name opened for the current document, a new window will be opened, otherwise the target references the matching window. If a new window is opened, the name property of the window will contain the value specified by the target property.
Default: _self.

Example HTML code 1:

This example illustrates the use of the target attribute:
<a id="myAnchor" href="frame.htm" target="TargetFrame">Click on it!</a>
<iframe name="TargetFrame" src="" height="150px" width="200px"></iframe>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the target property:
    <script type="text/javascript">
        function GetAnchorTarget () {
            var anchor = document.getElementById ("myAnchor");
            alert (;
    <a id="myAnchor" href="frame.htm" target="TargetFrame">Click it!</a>

    <br />
    The target of the link is the next iframe
    <br />

    <iframe name="TargetFrame" src="" height="150px" width="200px"></iframe>

    <button onclick="GetAnchorTarget ();">Get the target of the anchor!</button>
Did you find this example helpful? yes no

Supported by objects:

External links:

User Contributed Comments

Post Content

Post Content