Web Page Design: Frames

CS6204: Java and the WWW

References:


Frames Basics

  1. Document HTML.html, containing a contents list
  2. Document History.html, which is the first item listed in the contents
  3. Example of Web page with frames that combines 1 and 2


HTML generating above:
<HTML>
<HEAD>
   <TITLE>Frame Example</TITLE>
</HEAD>

<FRAMESET COLS="40%,60%">
  <FRAME SRC="HTML.html">
  <FRAME SRC="History.html">
</FRAMESET>
</HTML>

Targeting Frames

In our example, clicking on contents item replaces the left frame with the text. To replace the right frame, use the modifications is red below:


<FRAMESET COLS="40%,60%">
  <FRAME SRC="HTMLwithTargets.html" NAME="Contents">
  <FRAME SRC="History.html" NAME="Text">
</FRAMESET>

Next we must modify file HTML.html to list Text as the target frame in the text in red (call modified file HTMLwithTargets.html):


<HEAD>
   <TITLE>CS6204:  Web Page Design</TITLE>
   <BASE TARGET="Text">
</HEAD>




Click here to see the modified example.

An alternative to the last is to add the target attribute to each list item in the contents list. This would help if there were multiple content frames. For example:

From a software engineering viewpoint:

When Browsers Don't Support Frames

Add the following after a frameset to provide alternate text to browsers without frames enabled. (Web browsers ignore unknown HTML tags, so they will ignore the frameset tags, as well as the noframe tags, and hence only show the text below.)


<BODY>
<NOFRAME>

<UL>
<LI><A HREF="HTML.html">Contents</A></LI>

<LI><A HREF="History.html">Text</A></LI>
</UL>

<P></NOFRAME></P>

</BODY>

Nesting Framesets:

Example of Web page with nested framesets...

In this example, the window contains two columns. Nested within the left column is a frameset of two rows, and we put an image into the bottom row.


<FRAMESET COLS="50%,*">
  <FRAMESET ROWS="1*,1*">
    <FRAME SRC="HTMLwithTargets.html" NAME="Contents">
    <FRAME SRC="HTMLtools/Netscape Editor.gif">
  </FRAMESET>
  <FRAME SRC="History.HTML" NAME="Text">
</FRAMESET>

Other Frame Features

More attributes for frame tag: Here is the result if we make the modifications shown below...


<FRAMESET COLS="50%,*">
  <FRAMESET ROWS="1*,1*">
    <FRAME SRC="HTMLwithTargets.html" NAME="Contents" NORESIZE>
    <FRAME SRC="HTMLtools/Netscape Editor.gif">
  </FRAMESET>
  <FRAME SRC="History.HTML" NAME="Text" SCROLLING=NO>
</FRAMESET>

Note that you can no longer resize the panes, and the right frame now lacks scrollbars.

Some other frame target types...

TARGET="_blank"
Popping up a new blank window in which to display target URL
TARGET="_self"
Load URL into same frame as the document link is in
TARGET="_parent"
Load URL into document's parent's frame.
TARGET="_top"
Destroy all framesets and load the URL into the whole window -- required when you link to an external site.
Example:  Visit Web page with nested framesets and click on "Examples of Web Sites" and then choose a non-vt.edu site.  It shows up inside one of the frames!  When you do not want this behavior, _top is the solution.

Return to CS6204 home page.
Send comments to abrams@vt.edu.

Last modified on 16 June 1997. [This is http://ei.cs.vt.edu/~jwww/courseNotes/HTML/Frames.html.]