12 out of 23 rated this helpful - Rate this topic

target attribute | target property

[This documentation is preliminary and is subject to change.]

Sets or retrieves the window or frame at which to target content.

Syntax

HTML<element target="p" ... >
JavaScript

p = object.target

Property values

Type: String

name

The name of the target window or frame.

_blank

Load the linked document into a new blank window. This window is not named.

_media

Disabled in Windows XP SP2 and later versions; otherwise, loads the linked document into the HTML content area of the Media Bar. Available in Internet Explorer 6.

_parent

Load the linked document into the immediate parent of the document the link is in.

_search

Disabled in Internet Explorer 7, see Security and Compatibility in Internet Explorer 7 for details. Otherwise, loads the linked document into the browser search pane in Internet Explorer 5 or later.

_self

Default. Load the linked document into the window in which the link was clicked (the active window).

_top

Load the linked document into the topmost window.

Remarks

The window name is an optional argument in the open scripting method.

If there is no existing window or frame with the same name as specified in the target, a new window is opened with a name equal to the value of the target.

Windows Internet Explorer 8 and later. When Protected Mode is enabled and a webpage contains an anchor link with a named target, Windows Internet Explorer opens the target of the link in a new window when the target has a different integrity level than the webpage containing the link. For more information, see Understanding and Working in Protected Mode Internet Explorer.

In Internet Explorer 6, the value of the target parameter of this property specifies that a linked document loads in the content area of the target.

Metro style apps using JavaScript do not have multiple windows. To open a document within a new window by using TARGET = "new_identifier", the new identifier must identify an existing frame within the window.

Examples

This example uses the TARGET attribute to specify a link that loads the page into the topmost frame of the current frameset.


<A HREF="newpage.htm" TARGET="_top">Go to  Page.</A>

 

 

Build date: 3/8/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
new Tab vs. new Window
In both Firefox and Internet Explorer, whether a new window opens in a new tab or a new window is under the user's control, not the web site's.  (See Tools/Internet Options/Tabs.)  If you really want to AVOID a new tab, consider using showModalDialog.
Open Link In New Tab

To open a link in a new tab rather than a new window,

set your target to "_new" instead of "_blank".

This works with Netscape and Firefox, but unfortunately not with IE.

[EDIT: Beware of this misleading tip:

While often confused with "_blank", "_new" is in fact not a special value; it's just a window named "_new". Therefore, other links opened with target="_new" reuse the same tab/window and will NOT open a new one. Probably not what you intended.]