Frames allow you to split the browsers window up in to as many sections as you like, each capable of displaying its own document. Usually used for displaying a list of Contents (Links) on left side of the browser, which once clicked, display a document on the right side. When using frames, it's important you use the <!Doctype html public "-//wc3/dtd html 4.0 Final//en">
tag. As frames were only recognized by the w3c (world wide web consortium) as of version 4, the doctype tag ensures the file is correctly interpreted.
Here is the full source code for a simple frameset.
The code above is a complete script. You don't need to anything between the <BODY> tags. Although here's a good tip, pre version 4 browsers can not
render the frames
tags, so for these browsers the contents of the body tag will
be displayed. This is where I usually place a link to a free browser upgrade and a friendly note telling the user we are now in the 3rd millenium and that lasts millenniums browsers are not capable of 'viewing the content on this page'.
The file is telling the browser to split its window in to two frames and which documents to place in inside those frames.
The code in red
OK. First tag first. Open up a <FRAMESET> tag and use either the attribute rows=""
for creating rows, or cols=""
for creating columns. The attributes values ( separated with commas ) can be in the form of pixels for each frame as in cols="400,300"
or percentage as in cols="50%,50%"
or use the '*' for a variable value as in cols="100,*"
. You can add as many rows or columns as you like just use the <Frame> tag to define each frames information in order. Refer to the table 2 for its attributes. The frame tag is closed with </FRAME> and then the frame set is closed with </FRAMESET>
Note: Although Netscape 4 tries to understand pixel values in the frame tag, it is really putting your specified value through a complex calculation that rounds down the value through each step of the formula, thus returning a close, but inexact value. That is why you can never quite position frames precisely in Netscape. A well known, but undocumented bug.