spacer

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

home / experts / javascript / column7


Launching a Window with HTML

Developer News
ActiveState Debuts Open Source Business Suite
Salesforce Offers Visual App Builder
Codesion Steps Out From CVS's Shadow

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


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Use Web Caching to Make Your Web Site Faster · Creating an Online Shopping Cart Mechanism in PHP · Log JavaScript Errors Using an AJAX-driven Web Service
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Granular Settings for a Database Level Audit · The Perils of a Web 2.0 Transition on Your Business Processes · Facebook Redesigns Site —Again — Nears 400M Mark

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