spacer

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

home / experts / javascript / column7


Launching a Window with HTML

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

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

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji

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