Frames Tutorial part 3

What Is A Target?

You may specify a target whenever you create a link reference. This is not limited to frames, and in fact this is how GeoCities used to display its popup ads. If you are not using a frameset, then a new browser window is created with the name given in the target. If such a window already exists, it is reused. If a frame exists with that name, the page is displayed in that frame.

There are 4 special names that you may use as targets, and each starts with an underscore (not a dash):

_blank
always opens a new window. This is how I display the examples in this tutorial.
_top
replaces the entire frameset. Use this when you are loading someone else's page.
_parent
similar to _top. If you have nested framesets, loads the new page on top of the current frameset. For simple framesets (like these), it acts the same as _top.
_self
loads the page in the current frame. This is what happens if you do not give a target.

Building the Menu

For our application, we want each menu item to appear in the right hand frame, which is named info. The code to do this is shown below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META NAME="robots" CONTENT="noindex">
</HEAD>
<BODY BACKGROUND="../../images/whtmarb.jpg">
<TABLE>
<TR><TD>
<A HREF="framex1a.html" TARGET="info">The first link</A>
</TD></TR>
<TR><TD>
<A HREF="framex1b.html" TARGET="info">Another link</A>
</TD></TR>
<TR><TD>
<A HREF="framex1c.html" TARGET="info">Very_wide_link_in_the_menu</A>
</TD></TR>
</TABLE>
</BODY>
</HTML>
This looks like a normal HTML page, because it is one. It has a HEAD and a BODY and defines a background image. The links are contained in a TABLE, and they are regular anchors with HREFs. The only unusual feature is the use of TARGET in the links. I also added the line
<META NAME="robots" CONTENT="noindex">
to prevent search engines from indexing the page. While you do want to register your frameset with search engines, you do not want people to find your menu when they run a search.

To save some typing, and to minimize errors, you may change the default target for all the links. This new line goes into the HEAD block as shown below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META NAME="robots" CONTENT="noindex">
<BASE TARGET="info">
</HEAD>
<BODY BACKGROUND="../../images/whtmarb.jpg">
<TABLE>
<TR><TD>
<A HREF="framex1a.html">The first link</A>
</TD></TR>
<TR><TD>
<A HREF="framex1b.html">Another link</A>
</TD></TR>
<TR><TD>
<A HREF="framex1c.html">Very_wide_link_in_the_menu</A></TD>
</TR>
</TABLE>
</BODY>
</HTML>
On this page only, any link that does not specify a target will open in the info frame. You may still use TARGET to load certain links into other frames, or to load a page on _top.

Other Frames

What about the pages you want to display in other areas of the frameset? In other words, the pages that the menu loads into the right hand pane. They are perfectly normal HTML pages, with nothing to indicate that they are part of a frameset. That is one of the beauties of frames, in that any HTML page you have lying around may be displayed inside of a frameset.
Back to Frameset Code   On to JavaScript >  
1