The most common problem with frames is getting the links to open in the correct frame. This is called targeting. You give your anchor tags a "target" to open their links in. The target is usually the name of the frame.
The Four Standard Targets
There are four standard targets that don't require a named frame. These are targets that the user agents recognize:
- _self
This is the default target for any anchor tag. If you don't set a target or you use this target, the link will open in the same frame that the link is in. - _parent
If you think of a frameset as being a top level frame that is the entire Web site, and any frames within it are children of that frame. If you then nest additional frames in another page, they will be children of that page. This target opens the link in the parent of the current frame. - _top
This target will open the link at the very top of the frameset, removing all frames. - _blank
This is the most commonly used target - it opens the link in an entirely new window, similar to a popup.
Naming Frames to Target Specific Frames
When you build a framed Web site, it's a good idea to give each frame a specific name. This helps you remember what the frames are for and allows you to send links to those specific frames.
I like to name my frames for what they are for. For example:
<frame src="navigate.html" name="navigation" />
<frame src="main.html" name="main" />
Once you've named your frames, use the target attribute on your anchor tags. Target the frame name where you want the links to open.
<a href="new.html" target="main">A new page</a>

