TARGETING WINDOWS


This feature gives the document writer a little control over where the data appears when a user clicks on a link in their document. It is useful as a stand alone feature with a document space that can be best viewed with multiple top level windows (a list of subjects window, and a window displaying the current subject), but it is most useful in conjunction with Netscape's new frames feature.

How it works

Previously when a user clicked on a link, the new document either appeared in the window the user had clicked in, or alternately (and under the user's control) it appeared in a new window. Targeting windows allows the document writer to assign names to specific windows, and target certain documents to always appear in the window bearing the matching name.

A name is assigned to a window in one of three ways:

  1. A document can be sent with the optional HTTP header
    Window-target: window_name
    This will force the document to load in the window named window_name, or if such a window does not exist, one will be created, and then the document will be loaded in it.
  2. A document can be accessed via a targeted link. In this case there is actual HTML which assigns a target window_name to a link. The document loaded from that link will behave as if it had a Window-target set as in method 1 above.
  3. A window created within a frameset can be named using the NAME attribute to the FRAME tag.

How the HTML looks

Targeting withing HTML is accomplished by means of the TARGET attribute. This attribute can be added to a variety of HTML tags to target the links referred to by that tag. The attribute is of the form:
TARGET="window_name"

TARGET in an A tag.
This is very straightforward. The anchor tag normally specifies a link to be loaded when the active item is clicked on, adding the TARGET attribute to the anchor tag forces the load of that link into the targeted window. Example:
<A HREF="url" TARGET="window_name">Targeted Anchor</A>
TARGET in the BASE tag.
This is used when you want all (or most) of the links in a document to be targeted to the same window. In this case the TARGET attribute establishes a default window_name that all links in this document will be targeted to. This default is of course overridden by specific instances of the TARGET attribute in individual anchor tags. Example:
<BASE TARGET="window_name">
TARGET in the AREA tag.
The IETF Internet-Draft of Client-Side Image Maps defines an area tag. This tag describes a shaped area in a client-side image map, and provides the link that should be followed when the user clicks there. Adding the TARGET attribute to the area tag forces the load of that link into the targeted window. Example:
<AREA SHAPE="shape" COORDS="x,y,..." HREF="url" TARGET="window_name">
TARGET in the FORM tag.
The form tag normally displays the results of a form submission in the same window the form was submitted from. By adding the TARGET attribute to the form tag, the result of the form submission is instead loaded into the targeted window. Example:
<FORM ACTION="url" TARGET="window_name">

Allowed TARGET names

The window name specified by a TARGET attribute must begin with an alpha-numeric character to be valid. All other window names will be ignored.
Exception: There are magic target names that all begin with the underscore character.

Magic TARGET names

These names all begin with the underscore character. Any targeted window name beginning with underscore which is not one of these names, will be ignored.

TARGET="_blank"
This target will cause the link to always be loaded in a new blank window. This window is not named.
TARGET="_self"
This target causes the link to always load in the same window the anchor was clicked in. This is useful for overriding a globally assigned BASE target.
TARGET="_parent"
This target makes the link load in the immediate FRAMESET parent of this document. This defaults to acting like "_self" if the document has no parent.
TARGET="_top"
This target makes the link load in the full body of the window. This defaults to acting like "_self" if the document is already at the top. It is useful for breaking out of an arbitrarily deep FRAME nesting.