You are here: Reference > JavaScript > client-side > HTML DOM > properties > target (a, area, base, form, link)
target property (a, area, base, form, link)
Specifies or returns the target window or frame where the document is to be opened.
Syntax:
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. | |||||||
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?
|
Example HTML code 2:
This example illustrates the use of the target property:
|
|||||
<head> <script type="text/javascript"> function GetAnchorTarget () { var anchor = document.getElementById ("myAnchor"); alert (anchor.target); } </script> </head> <body> <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> </body> |
|||||
|
|||||
Did you find this example helpful?
|
Supported by objects:
External links:
User Contributed Comments