Window Spawning and Remotes: Launching a Window with HTML - Doc JavaScript | WebReference

Window Spawning and Remotes: Launching a Window with HTML - Doc JavaScript


Launching a Window with HTML

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

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