|
|
||||||||||||||||||||||||||
|
|
Frames | Simple Examples |
|
|
|
||||||||||||||||||||||
Simple Examples
Let's begin learning how pages that use frames are constructed by first looking at a few very simple schematic examples. In each case we will show the HTML code that is used to create the frame set and load files into the various frames. Most of this code is shown in a blue font to set off the code from the surrounding discussion. In some cases, portions of the HTML are shown in a red font to emphasize important differences in two sections of HTML that we are comparing. We will also illustrate the frame set that this code creates by showing the frames in a new broswer window that we open with Javascript.
Don't be confused by our use of new windows to illustrate the frame sets.
You don't need to use a new browser window to use frames.
We only open the example frame sets in new windows here:
Also note that we open the new windows with Javascript here rather than with HTML
simply because we want the new windows to have minimum browser adornments
(no point having extra buttons and menus getting in the way) and because
we want to be able to control the size of the new windows. A little later we'll
discuss how the size of a frame set relates to the size of window that contains the
frame set.
Very Simple Frame Sets -
Two Rows or Two Columns
Two Rows - Let's begin our consideration of frames with Example 1. This is a frame set with two rows: the top frame takes up 20% of the available vertical space and the bottom frame takes up 80% of the available vertical space. The HTML code used to create this first frame set is:
Two Columns - As our second example, here is a frame set with two columns: Example 2. The left frame takes up 20% of the available horizontal space, and the right frame takes up 80% of the available horizontal space. The HTML code used to create this second frame set is:
The red text, as we mentioned earlier, is used here to indicate the only difference in the HTML code for the two examples.
The most important things to notice in these examples are:
The frameset and frame tags may have additional attributes that will allow further customization of a frame set and/or endow the frame set with additional functionality. We begin our discussions by considering only the minimum attributes that these tags must have; we'll take a look at some of the other features later. In these examples file1.html and file2.html are very simple files; each just has a short piece of text on a solid color background:
Here is file1.html displayed in a window by itself, and here is file2.html displayed by itself. We chose these simple files to load into the frame set because we wanted to emphasize the structure of the frame set and how to create it, not obscure matters with particular material in the files that are loaded into the two frames.
In fact, however, you can load into any frame any
HTML file (even a full frame set), any image file, or any other type of file that can
be displayed inline on a web page.
The files can, of course, be either local files or files anywhere on the web, as
long they are specified with the correct local path or URL.
Example 1 Reversed
You've probably guessed by now that if you want to interchange the frames in our first example, all you need to do is switch the values in the list assigned to rows:
Here's the new frame set this modified code creates: Example 3. But now file1.html is in the large frame while file2.html is in the small frame. If we also want to switch the files as well as the two frames to get Example 3a, it should be clear what we need to do:
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||