HTML Frames

Many people are intimidated by frames. Mainly because at first glance, it seems very difficult to put so many things together on to one screen. Actually, there is only two components (in two separate files) that make frames work. The first file is the layout file, it defines were and how the frames will be put on the screen. The second half consists of source files which are the actual information that is displayed in the frames.

The Layout File


The layout file defines where the frames will placed on the screen and how large they will be. The layout file will start out the same as any other HTML file. You will have a heading, but instead of <BODY> and </BODY> tags, you will have two new tags. These new tags are <FRAMESET> and </FRAMESET> which actually define the placement of the frames by using either the ROWS parameter of the COLS parameter. See the below template for how to use these parameters.
 	<FRAMESET COLS = "size,size">
		OR
	<FRAMESET ROWS = "size,size">
size is the width of the frame if you defined the frames as columns or the height of the frame if you defined the frame as rows. You can define the size in two ways, either by using pixels or by using a percentage of the screen. When you want to define the size by pixels, simply enter the number of pixels in for size. If you want to use a percentage of the screen, put a percentage mark (%) directly after the number where size should be.

For every size parameter that you include in your </FRAMESET> tag, you must have a <FRAME SRC> tag, which are in the form:

 	<FRAME SRC = "filename.html" NAME = "frame_name">
filename.html is the name of the source file, which contains the information that you want in that frame.
frame_name is the name that you want to give that frame. It is important that you give each of your frames different names and be sure to remember what you named each frame. This name will be used later when you decide to change to another page inside that frame, which will be discussed later.

A sample of a layout file would be something like this:


<HTML>
<HEAD>
<TITLE>Frame Example</TITLE>
</HEAD>

<FRAMESET COLS = "50%,*">
   	<frame src="example1.html" name="Menu">
	<frame src="example2.html" name="Main">
</FRAMESET>

</HTML>

example1.html and example2.html are the example files that I used in previous sections. This file would look like this.

Targeting Frames


This is all that their is to laying out the frames, and getting the initial web pages loaded into them. The only thing left is knowing how to change these initial pages, and this is very easy. When making links in framed pages, you need to add the parameter TARGET to your anchors. This new anchor would take the form:
<A HREF = "filename or address" TARGET = "frame_name"> 
frame_name is the name that you gave the frame in the <FRAME SRC> tag. The designated page will load into that frame. This is why you must not name two frames the same thing and why it is important to remember the name you gave the frame.

Netscape also gives several other special targets that can be useful. You can use these special target names in place of "frame_name."
_self directs the browser to update the frame containing the selected hyperlink. This is usually the default target when no target is specified.
_top directs the browser to update the entire window, regardless of the current frame layout.