HTML Reference Guide
Author: Randy D. Ralph.  In place February 23, 1999.  Copyright © 1999 NetStrider.  Presented as a public service.
You are here:  NetStrider » Tutorials » HTMLRef » FRAMES »
BACKnextFRAMES
<FRAME> <FRAMESET> <NOFRAMES>
Command Parameters Example Command Parameters Example Command Parameters Example

<<>><<>><<>><<>> Follow this link to see this document in FRAMES <<>><<>><<>><<>>

Introduction
Framed documents consists of static frames defined by framesets.  Each frame contains its own HTML document which is loaded and displayed independently of the documents displayed in any other frame.  That is the unique capability of the framed document.  HTML code can be targeted to, loaded dynamically and displayed independently in any defined frame without altering the fundamental display characteristics of the underlying design of the document frame structure or changing the contents of any other frame.

There are advantages and disadvantages to framed HTML documents. 

Advantages Disadvantages
 
  • The content of any frame can be changed dynamically and, in higher-end browsers, reloaded dynamically.

  • Each frame is independent of every other frame.

  • The user can be given control over the size of frames.

  • Navigation of page contents can be made easier for the user.
 
  • Framed documents are considerably more difficult to manage and maintain than ordinary HTML documents.

  • Many Internet users do not like frames and find them annoying.

  • Low-end browsers (below 2.x) are not frames capable.

  • Users can get trapped in frames within frames within frames.

Earlier versions (2.x and below) of all browsers are not capable of displaying framed documents so it is advisable to include a <BODY> HTML Document Segment following the frameset enclosed within the <NOFRAMES> </NOFRAMES> command tag pair.  Browsers which are not frames capable will selectively ignore the frameset and load the code contained within the noframes HTML Document Segment.

Many Internet users do not like framed documents because they are prone to display difficulties generally caused by poor coding.  It is advisable to provide a means to escape to a non-framed alternative and a means to clear the existing frameset and replace it with a fresh one.  Many HTML developers fail to provide these alternatives, which has probably helped to foster a general aversion to framed documents.

Framed documents require considerably more effort to develop and maintain than non-framed documents.  Their use should be restricted to applications in which the special features they offer are necessary.  Some of the display functions of frames can be accomplished with tables.

<FRAME> Command
<FRAME src="URL" command parameters>

Establishes, defines and loads a frame in a framed HTML document.

The command tag is unpaired since a frame is an object.

See also:  <FRAMESET>, <IFRAME>, <NOFRAMES>

Primary Command Parameters:

src="URL"

Defines the location (URL) of the HTML code that will be loaded into the frame.


name="frame name"

Defines the name by which the frame will the targeted in hypertext reference links.

Below is a list of reserved names which have special meaning in HTML and cannot be used as frame names with a framed document:

_blank loads the HTML code into a new browser window.
 
_self loads the HTML code over itself in the current window or frame.
 
_parent loads the HTML code over the parent document, if any. _top loads the HTML code at the top level of the current browser window.

Note that all these reserved names begin with the underscore character ( _ ).

Secondary Command Parameters:
bordercolor="color name | color value"

Defines the color to be used to draw the frame border in the Netscape browser.  The value can be expressed either as a named color or a hexadecimal color value.  The parameter can also be used at the frameset level to establish a global frame border color.

frameborder="pixels | yes | no"
frameborder/noframeborder

Defines the dimensions and presence or absence of a border around the frame.

The Netscape browser uses values of yes | no which merely determine whether or not a border will be drawn around the frame.  In the Netscape browser all contiguous frames share a common border. The default condition is on - yes.

It is best to use this parameter at the frameset level.  Otherwise all contiguous frames must have the same value set in order for the parameter to work properly.

The alternate frameborder/noframeborder parameter pair toggle frame borders on and off.  The default is on - frameborder.

The Internet Explorer browser takes a pixel argument for the parameter.  If the pixel value is set to 0 then the border is not drawn.

framespacing="pixels"

Used only in the Internet Explorer browser, this parameter defines the pixel value to be set on the whitespace or standoff surrounding a frame outside its border.  This gives the appearance of a frame within a frame.

marginwidth|marginheight="pixels"

Defines the pixel value to be set on the width and/or height, respectively, of the margins ( whitespace or standoff ) surrounding the contents of a frame.

scrolling="auto | yes | no"

Establishes whether or not the user can scroll the contents of a frame.  A value of auto allows the browser to determine if scroling is necessary in order for the frame to be viewed properly.

noresize

Prevents the user from resizing a frame.  By default, all frames are resizable.  It is unwise to prevent frame resizing unless it is certain that the frame contents will view properly at all screen resolutions without the capability.

Example:
<frameset rows="100,*"> <frameset cols="50%,50%"> <frame src="banner1.html" tppabs="http://www.netstrider.com/tutorials/HTMLRef/frames/banner1.html" name="banner1"> <frame src="banner2.html" tppabs="http://www.netstrider.com/tutorials/HTMLRef/frames/banner2.html" name="banner2"> </frameset> <frameset cols="25%,75%"> <frame src="toc.html" tppabs="http://www.netstrider.com/tutorials/HTMLRef/frames/toc.html" name="toc"> <frame src="javascript:if(confirm('http://www.netstrider.com/tutorials/HTMLRef/frames/intro.html \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found. \n\nDo you want to open it from the server?'))window.location='http://www.netstrider.com/tutorials/HTMLRef/frames/intro.html'" tppabs="http://www.netstrider.com/tutorials/HTMLRef/frames/intro.html" name="display"> </frameset> </frameset> In the complete frameset defined above the innermost nested elements are the <FRAME> elements.  These define the location of the HTML code that will be loaded into and displayed in each of the four independent frames in the example above.

Note that the entire frameset contains three <FRAMESET> command elements.  Two secondary framesets are nested within the primary frameset.  Proper nesting of elements is the key to successful frames coding.

The frameset elements set up the rows and columns for the display of the framed document.  In this example, the primary frameset sets up two rows.  The secondary framesets set up the columns within each row independently of one another.

<FRAMESET> Command
<FRAMESET command parameters></FRAMESET>

Defines and contains a Framed HTML Document Segment in an HTML document consisting entirely and only of a frameset.  A single frameset can define either columns or rows.  To define both columns and rows within a framed document it is necessary to have at least two framesets, one defining the columns and one defining the rows.

Only <FRAME> and other <FRAMESET> elements are permitted with a frameset.

The frameset replaces the <BODY> HTML Document Segment and must be defined immediately following the <HEAD> HTML Document Segment.

See also:  <FRAME>, <IFRAME>, <NOFRAMES>

Primary Command Parameters:

cols="pixels | % | *"

Defines the number and dimension of the columns within a frameset.  The number of columns within the frameset is determined by the number of dimensions specified in the comma-delimited list.  Column width can be defined using absolute pixels, a percent of the space available or the asterisk wildcard *.

Examples:

    cols="50,50,*"

    Defines three columns.  The first two columns would both be 50 pixels wide and the third column would occupy the remaining available display width.

    cols="25%,75%"

    Defines two columns.  The first column would occupy 25% of the available display width and the second column 75% of the available display width.

    cols="33%,*,33%"

    Defines three columns.  The first and third columns would occupy 33% of the available display width and the center column would occupy the remainder of the available width.


rows="pixels | % | *"

Defines the number and dimension of the rows within a frameset.  The number of rows within the frameset is determined by the number of dimensions specified in the comma-delimited list.  Row height can be defined using absolute pixels, a percent of the space available or the asterisk wildcard *.

Examples:

    rows="200,100,*"

    Defines three rows.  The first row would be 200 pixels high and the second row 100 pixels high.  The third row would occupy the remaining available display height.

    rows="50%,50%"

    Defines two rows.  Both rows would occupy exactly 50% of the available display height.

    rows="25%,*,25%"

    Defines three rows.  The first and third rows would occupy 25% of the available display height and the center row would occupy the remainder of the available display height.

Secondary Command Parameters:
border="pixels"

Allows a global value to be set on the width, in pixels, of all borders surrounding defined frames within a frameset.

bordercolor="named color | color value"

Allows a global value to be set on the color, using either Netscape named colors or hexadecimal color values.

frameborder="yes | no"

Allows frame borders on all defined frames within a frameset to be turned on or off.  The default is on - yes.

Example:
<frameset rows="100,*"> <frameset cols="50%,50%"> <frame src="banner1.html" tppabs="http://www.netstrider.com/tutorials/HTMLRef/frames/banner1.html" name="banner1"> <frame src="banner2.html" tppabs="http://www.netstrider.com/tutorials/HTMLRef/frames/banner2.html" name="banner2"> </frameset> <frameset cols="25%,75%"> <frame src="toc.html" tppabs="http://www.netstrider.com/tutorials/HTMLRef/frames/toc.html" name="toc"> <frame src="javascript:if(confirm('http://www.netstrider.com/tutorials/HTMLRef/frames/intro.html \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found. \n\nDo you want to open it from the server?'))window.location='http://www.netstrider.com/tutorials/HTMLRef/frames/intro.html'" tppabs="http://www.netstrider.com/tutorials/HTMLRef/frames/intro.html" name="display"> </frameset> </frameset> Note that the complete frameset defined above contains three <FRAMESET> command elements and that two secondary framesets are nested within the primary frameset.  Proper nesting of elements is the key to successful frames coding.

The frameset elements set up the rows and columns for the display of the framed document.  The primary frameset sets up two rows.  The secondary framesets set up the columns within each row independently of one another.

The innermost nested <FRAME> elements define the location of the HTML code that will be loaded into and displayed in each of the four independent frames.

<NOFRAMES> Command
<NOFRAMES>
  <BODY>
    Alternate Non-Framed HTML Code
  </BODY>

</NOFRAMES>

Provides a container for alternate non-framed HTML Code within a framed HTML Document.  Browsers which are not frames capable will ignore all defined framesets and load the code contained within the defined Noframes Document Segment.  This document segment should contain a normal HTML Document <BODY></BODY> Segment.

The command requires no parameters.

See also:  <FRAMESET>, <FRAME>, <IFRAME>.

Example:
<NOFRAMES> <BODY> Alternate Non-Framed HTML Code <!-- copyright (i1) --><div align="center"><a href="http://www.ucoz.ru/" title="Создать сайт бесплатно"><img style="margin:0;padding:0;border:0;" alt="Hosted by uCoz" src="http://s204.ucoz.net/img/cp/5.gif" width="80" height="15" title="Hosted by uCoz" /></a><br /></div><!-- /copyright --> </body> </NOFRAMES> The noframes segment contains the HTML Document Body Segment.  This segment contains HTML code which low-end browsers, incapable of interpreting frames, will load and display as an alternate to the framed document.  Any parameters set within the <BODY> command will define global display properties of the non-framed page.  These are ignored when the framed document is loaded since each frame contains HTML source code independent of all other frames.
Return to Section E:H

Hosted by uCoz