To use frames, you need a special HTML page to contain frameset and /frameset tags in place of the usual body and /body tags. In addition, you will need HTML pages or other files to display in the frames and/or scripts to generate content for the frames.
The frameset tag must have either a rows attribute or a cols attribute or both; the values of these attributes should be comma-delimited lists of widths/heights of the areas to be occupied by the frames; the default unit is pixels, but percentages are often more useful.
Between the frameset tag and the /frameset tag, one or more frame elements are inserted. A frame tag will usually have at least a name attribute. If you want something displayed initially in the frame, the frame tag should also have a src attribute. A frame for which there is no room, given the rows and cols values of the frameset, will not be displayed.
In addition to the frame tags, you can insert other HTML code providing information for anyone using a browser that does not support frames. A browser that does support frames will just ignore this code.
Here is a simple example:
<html> <head> <title>LIS 523/5 - Frames</title> </head> <frameset cols="70%,20%"> <frame src="525fra.htm" name="leftFrame"> <frame name="rightFrame" src="about:blank"> This page uses frames, which your browser does not support. <p> <a href="525fra.htm">Show just the information page</a>. (Frame demonstrations will not work.) </frameset> </html>
When designing framesets, note that refreshing or reloading the page in the browser does not update the frameset, but just the individual frame contents. If you modify the frameset (say, by changing columns to rows), you need to request the page again explicitly by URL or by opening it as a file.
If this is not desirable, the form of the link can be changed by providing an appropriate value for the target attribute. If target is set to "_parent", clicking on the link replaces the whole frameset with a rendering of the new file. If target is set to "_top", clicking on the link replaces the entire browser window contents with a rendering of the new file. This is how the links at the bottom of this page work. If target equals "_blank", another window will be opened for the new file.
The value of target may also be the name of a frame. For example, the following link loads the instructor's home page into the righthand frame: Tim Craven.
For more complex examples that make use of this sort of dynamic frame filling, see the quizzes in the Thesaurus Construction Tutorial.