14.5. Targeting Frames
One of the challenges of managing a framed document is coordinating where linked documents display. By default, a linked document loads into the same window as the link; however, it is often desirable to have a link in one frame load a page into a different frame in the frameset. For instance, this is the desired effect for a list of navigation links in a narrow frame that loads content into a larger main frame on the page.
To load a new linked page into a particular frame, you first need to assign a name to the targeted frame using the name attribute in the <frame> tag, as follows:
<FRAME SRC="original.html" NAME="main">
Now you can specify that frame by name within any anchor (<a>) tag with the target attribute, as shown in this example:
<A HREF="new.html" TARGET="main">...</A>
The document new.html will load into the frame named "main".
If a link contains a target name that does not exist in the frameset, a new browser window is opened to display the document, and that window is given the target's name. Subsequent links targeted to the same name will load in that window.
14.5.1. The <base> tag
If you know that you want all the links in a given document to load in the same frame (such as from a table of contents into a main display frame), you can set the target once using the <base> tag instead of setting the target within every link in the document (saving a lot of typing and extra characters in the HTML document).
Placing the <base> tag in the <head> of the document, with the target frame specified by name, causes all the links in the document to load into that frame. The following is a sample targeted base tag:
<HEAD> <BASE TARGET="main"> </HEAD>
Targets in individual links override the target set in the <base> tag at the document level.
14.5.2. Reserved target names
There are four standard target names for special redirection actions. Note that all of them begin with the underscore ( _ ) character. You should avoid naming your frames with a name beginning with an underscore as it will be ignored by the browser. The four reserved target names are:
Figure 14-7. In nested framesets, the _parent target links to the parent frameset
Figure 14-8. Linking with the _top target replaces the entire frameset
Copyright © 2002 O'Reilly & Associates. All rights reserved.