spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column7


Launching a Window with HTML

Developer News
Eclipse Helios Update Brings New PHP Tools
Internet Explorer 9 Ups Standards Support
JBoss Portal 5 Release Easier to Use

The TARGET attribute lets you specify a link's target window. It can also be used to provide a form's response target. Its general syntax is:

<A HREF="..." TARGET="windowName">...</A>
<FORM ACTION="..." METHOD="..." TARGET="windowName">...</FORM>

windowName can be any plain string. It causes the new URL (or form response page) to load in the specified window. If another link hasn't already been loaded in a window with that name, the browser generates a new window for the page. For example, click here to load another copy of this page in a window named "same." Once it has loaded, click here to load the column's previous page in the same window. Make sure you return to the original window before you click. How did we do that? The following HTML code defines these two links:

Click <A HREF="htmllaunch.html" TARGET="same">here</A> ...
Click <A HREF="index.html" TARGET="same">here</A> ...

Another important point is that the new window has the exact same properties as the original one. That is, they have the same height, width, and toolbars.

You can take advantage of the TARGET attribute to load a document into a specific window or frame, if you know that window's name. Simply specify the window's name as the attribute's value.

HTML provides several standard targets (windowName) with special meanings:

TARGET="_blank"
The browser should load the designated document in a new, unnamed window. Use this attribute to force the document to load in a new window.
TARGET="_self"
The browser should load the document in the same frame as the element that refers to this target. This attribute is actually the default one.
TARGET="_parent"
The browser should load the document into the immediate parent of the current frame. This value is equivalent to _self if the current frame has no parent.
TARGET="_top"
The browser should load the document into the full, original window (the top-level window). This value is equivalent to _self if the current frame has no parent.

It is also possible to set the default target for all links and forms in a page. Simply place the following definition in the document's <HEAD>...</HEAD> portion:

<BASE TARGET="windowName">

http://www.internet.com

webref The latest from WebReference.com Browse >
Flashmaps' DynamicLocator: Interactive Maps for Small Areas · Flashmaps' AreaSelector: Interactive Maps for Wide Areas · The DB Mapper: Interactive Street-level Maps of U.S. and Canada
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags

Created: November 18, 1997
Revised: December 4, 1997
URL: http://www.webreference.com/js/column7/htmllaunch.html