|
|
Frames in HTMLCurrently, frames are only supported by Netscape 2 and above, and Microsoft Internet Explorer 3. For some more detailed tag descriptions, see Netscape's Implementation of Frames. There are also some further tips in the Guide's FAQs, including how to target two frames from one link.
Frames are displayed through a Frame Definition document. The frame definition describes the number and position of the frames and the URL of their contents. You cannot write the contents of the frames within the frame definition - these must always be held in separate documents.
|
frameset
|
frame
|
no frames
|
targets
|
example
|
floating frames
|
<frameset><body> tag is replaced by the
<frameset> tag. The <frameset> tag will
be ignored if any tags normally found within the <body> element are placed
before it. The <frameset> container holds the
<frame> elements which describe the frames that will make up the
page. As you will see, the <frameset> tag can be nested where
necessary.
rows="x1,x2,...|x1%,x2%,...|x1*,x2*,..."*) is used to designate rows that are
relatively sized.
<frameset rows="2*,*">
<frameset rows="50,*,50">
would fix the height of the top and bottom frames and allocate the remaining space in the
window to the middle frame.
<frameset rows="20%,60%,20%">
would display a large middle frame between two smaller frames.
cols="x1,x2,...|x1%,x2%,...|*"rows attribute.
frameborder="yes|no|0"yes
and no, while MS Internet Explorer uses the value
0 (zero). Therefore to be sure the frame border is turned off, you
must use the attribute twice. This attribute can be used with the <frame> tag to set the borders for a single
frame.
border="value"bordercolor="#hexcolor"<frame> tag to set the border colour for a
single frame.
<frame>src="URL"<img>. If no
src attribute is specifed, the frame will remain as blank space.
name="window name"target attribute.
The name must begin with an alphanumeric character.
scrolling="yes|no|auto"auto, which lets the browser decide whether the frame needs scrollbars
and display them where necessary.
noresizenoresize attribute will prevent the user from resizing the frame. By
default the user can resize frames by dragging the the frame edge to a new position.
marginwidth="value"marginheight="value"marginwidth, this attribute allows the user to set the frame margin
height in pixels. By default, the browser will decide upon an appropriate margin height.
<frame src="example.htm" name="frame1" scrolling="yes"
marginwidth="10" noresize>
bordercolor="#hexcolor"<frameset> tag to set the border colour
for a group of frames.
framespacing="value"
MS Internet Explorer only. This attribute allows the user to clear space
around the frame; defined in pixels.
frameborder="yes|no|"
This attribute enables you to turn off the border around a frame. Currently Netscape
Navigator (version 3 only) uses the values yes and
no, while MS Internet Explorer uses the value
0 (zero). Therefore to be sure the frame border is turned off, you
must use the attribute twice. To completely get rid of a frame outline in
MSIE you muist also set the framespacing attribute to
0 (see first example below). This attribute can be used with the <frameset> tag to set the borders for a
group of frames. Note: frame borders will only be turned off if
both adjacent frames (even if they are in different framesets) have their
frameborder attributes set accordingly.
<frame src="example2.htm" name="frame2" frameborder="no"
framespacing="0">
<frame src="example3.htm" name="frame3"
bordercolor="#FF0000">
<noframes>noframes tags will not
be displayed by a frames-capable browser. This tag is useful for providing a link to pages
that do not use frames.
In order to direct data to a different frame, the receiving frame must have been named in the frame definition. In the example below, a link in frame 5 directs the file
x_frame6.htm is into in a frame called frame3. This is
done by including the
If the name in the
There are some special target names, called magic target names. These all
begin with an underscore ( target
The target attribute is not found in the frame definition but is used within normal HTML
documents to direct data to specific frames. Normally when a user clicks on a link, the new
document appears in the same window or frame as the link. The target
attribute is used to direct data to a specific. ie. a different, frame or window. We shall
consider the target attribute in terms of frames and the <a> tag. The
target attribute can also be used with the base, area and form tags.target attribute in the <a> tag in the following way:
<A TARGET="frame3" HREF="x_frame6.htm">
target attribute does not exist, the document in the link
will be opened as a new window with a name as given in the target
attribute. The names must all begin with an alphanumeric character._ ).
target="_self"
target="_parent"
target="_top"
target="_blank"
Example+------------+-------------------------+------------+ | | | | | | | | | | | | | | | | | | | | | | | | +------------+------------+------------+------------+ | | | | | | | | | | | | | | | | | | +-------------------------+-------------------------+
The Frame Definition
<html> <head> <title>Sizzling HTML Jalfrezi - frames example</title> </head> <FRAMESET ROWS="50%,50%"> <FRAMESET COLS="150,*,150"> <FRAME SRC="x_frame1.htm" SCROLLING="yes"> <FRAME SRC="x_frame2.htm"> <FRAME SRC="x_frame3.htm" NAME="frame3"> </FRAMESET> <FRAMESET COLS="50%,50%"> <FRAME SRC="x_frame4.htm" MARGINHEIGHT=50 MARGINWIDTH=50> <FRAME SRC="x_frame5.htm"> </FRAMESET> </FRAMESET> <NOFRAMES> You do not have a frame-compatible browser - this example won't work without one.<BR> <A HREF="frames.htm">Click here</A> to return to the Frames page. </NOFRAMES> </HTML>
The example shows all of the features of frames described above, including targeting
windows and the noframes feature for non-frame compatible browsers.
Floating Frames
Microsoft Internet Explorer 3.01+ now supports the so-called
floating frame. This is rendered using the <iframe> tag.
| Sizzling HTML Jalfrezi | |
| ©1997 Richard Rutter | ![]() |
| rrutter@woodhill.co.uk | |