Using FramesWeb designers use frames to control what is displayed in various parts of a browser window. For instance, you might want to display a menu file at the top, bottom, or one side of a browser window, while displaying other content in the rest of the window. The menu would be a constant feature of your Web site a reader could click on the menu to view various files. This would reduce the number of mouse clicks (and file loads) needed to view various parts of your site. Frames have a poor reputation among some Web designers for three reasons:
In this guide, I'll lay out some sample framed pages and identify attributes that can be used to control the appearance of frames. To understand how to design Web sites using frames, you need to know about the frameset, frame, iframe, and noframes tags. I will also discuss the importance of and illustrate procedures for targeting your links in a framed page. Note: Although relatively few users seem to be using early versions of browsers anymore, you should know that frames are supported by versions 2.x and above of Netscape Navigator and versions 3.x and above of Microsoft Internet Explorer. Internal frames are supported only by Internet Explorer 3.x and above and Netscape Navigator 6.x and above. A Simple Frameset<HTML> <HEAD> <TITLE>A Simple Frameset</TITLE> </HEAD> <frameset cols="110,*"> <frame name="menu" src="menu.cfm" marginwidth="10" marginheight="10" scrolling="auto" frameborder="yes"> <frame name="main" src="main.cfm" marginwidth="10" marginheight="10" scrolling="auto" frameborder="no"> </frameset> </HTML> ![]() Note that this frame layout divides the screen into two columns. The first frame (column) is 110 pixels wide, while the second occupies the rest of the screen. The first frame is named "menu" and displays the file "menu.cfm." The second frame is named "main" and displays the file "main.cfm". Additional parameters for the frames specify margin width and height, whether the frame displays a scroll bar, and whether it has a border. A More Complicated Frameset<HTML> <HEAD> <TITLE>A More Complicated Frameset</TITLE> </HEAD> <frameset rows="50%,*" cols="50%,*"> <frame name="welcome" src="howdy.cfm" marginwidth="10 " marginheight="10" scrolling="auto" frameborder="yes"> <frame name="credits" src="openingcredits.cfm" marginwidth="10" marginheight="10" scrolling="auto" frameborder="yes"> <frame name="notes" src="firstnote.cfm" marginwidth="10" marginheight="10" scrolling="auto" frameborder="yes"> <frame name="copyright" src="copyright.cfm" marginwidth="10" marginheight="10" scrolling="auto" frameborder="yes"> </frameset> </HTML> ![]() This frame divides the screen into four equal regions, much like a checkerboard. Each frame has a name and an initial file identified, as well as specific attributes concerning margins, borders, and scrollbars. Embedded Framesets and the NoFrames Tag
<HTML>
<HEAD>
<TITLE>Embedded Framesets with the NoFrames Tag</TITLE>
</HEAD>
<frameset rows="*,38" bordercolor="#003399">
<frameset cols="50%,*">
<frame name="list" src="list1.cfm" scrolling="auto"
frameborder="1">
<frame name="pop" src="blank.cfm" scrolling="auto"
frameborder="1">
</frameset>
<frame name="menu" src="menu.cfm" scrolling="auto"
frameborder="1" marginheight="3" marginwidth="0">
</frameset>
<noframes>
<base target="main">
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#3366FF"
VLINK="#003399" ALINK="#0000FF">
<FONT FACE="Times New Roman, Times, Roman" SIZE="+3" COLOR="#336600">
<B>The Writing Center at Colorado State University</b></font>
<p>The Writing Center offers support to students and teachers of writing.
We provide links to a range of online writing resources, interactive tutorials,
annotated example texts, and instructional materials addressing writing, writing
Instruction, composition, composition instruction, writing across the curriculum
WAC, communication across the curriculum CAC, online tutoring, speech
communication, technical communication, computers and writing, and computers and
composition. We also provide links to numerous online writing courses, speaking
courses, and courses across the curriculum.</p>
<B>Important Note: </B>Most of the subsections on this site use frames.
If your browser does not support frames, please consider upgrading to a more recent
version of Netscape Navigator, Microsoft Internet Explorer, Opera, or another
frames-capable browser.
</BODY>
</noframes>
</HTML>
This frameset lays out some of the pages on Colorado State University's Writing Center Web site. The first frameset divides the page into two rows and specifies the bordercolor for the frames. The second frameset divides the first row into two columns. The noframes tag allows us to display the page within browsers that do not support frames. An Internal FrameAn internal frame also referred to as a floating frame appears within a particular page. It is supported in the W3C 4.0 specification and is supported by Internet Explorer 3.x and higher, and by Netscape Navigator 6.x and higher. <HTML> <HEAD> <TITLE>Using an Internal Frame</TITLE> </HEAD> <BODY BGCOLOR="Yellow" TEXT="#000000" LINK="#3366FF" VLINK="#003399" ALINK="#0000FF"> <h1>Using an Internal Frame</h1> <p><IFRAME SRC="example.cfm" NAME="my_iframe" Height="100" WIDTH="300" FRAMEBORDER="1">I</IFRAME ALIGN="RIGHT">This page is designed to illustrate how to use an internal frame. As you can see, it is located on the right side of the page, using specific pixel widths and height.</p> </BODY> </HTML> ![]() The internal frame is located at the same height as the paragraph tag in which it is placed, aligned right on the screen. The height and width of the internal frame are specified in the IFRAME tag. An internal frame can have scrollbars and can be made nonresizeable. You will find the specific attributes for the IFRAME tag below. The FRAMESET TagThe FRAMESET tag is the main tag for a frame. It is placed after the HEAD and before the BODY tags in an HTML document. Each frameset can contain the code for multiple frames. It can also contain the code for additional framesets. (Just as you can nest tables within other tables, you can nest framesets.) The attributes for the frameset tag allow you to define the rows, columns, and border characteristics of a frameset. Examples of these attributes are found below:
The FRAME TagThis element defines a single frame in a frameset. The attributes for the frame tag allow you to define the source, name, margin, scrolling, resizing, and border characteristics of a frame. Examples of these attributes are found below:
The IFRAME TagThe IFRAME tag specifies an internal or floating frame. It is supported in the W3C HTML 4.0 specification, but is implemented only in Internet Explorer 3.x and higher and in Netscape Navigator 6.x and higher. The attributes for the IFRAME tag allow you to define its source, name, height, width, scrollbars, resizing, and border characteristics. These attributes are described below:
The NOFRAMES TagThe NOFRAMES tag allows you to display content in browsers that do not support frames. The tag itself is not actually recognized by browsers that don't support frames. However, the default for tags that are not recognized by a browser is to ignore the tag. It turns out, then, that a browser that doesn't recognize frames will ignore all your frameset and frame tags, ignore the NOFRAMES tag, and instead display the HTML tags that it does recognize. In contrast, browsers that do support frames will display the frames and ignore the information within the <NOFRAMES> and </NOFRAMES> tags. You can find an example of the use of the NOFRAMES tag earlier in this document, in Embedded Framesets and the NoFrames Tag. It's usually a good idea to display a warning using the NOFRAMES tag on the index page of a site that uses frames. You can let your readers know that you've used frames, rather than simply leaving them with a blank page. Targeting LinksTo support navigation in a framed site, you need to "target" your links. This is accomplished using the TARGET attribute in the Anchor tag. For instance, if you have set up a frameset with a left column named "menu" and a right column named "main", you could target the links in the file menu.cfm (which you could display in the "menu" frame) so that clicking on them would cause the files to display in the "main" frame. A link using the target attribute might appear as: <A HREF="background.cfm" TARGET="main">
Failing to Use the TARGET Attribute: Failing to use the TARGET attribute will cause a file to open in the current frame. In the case of a site using a menu frame, failing to target your links would certainly defeat your purposes. Failing to Name a Target Properly: Failing to use the right name for a target will cause the file to open in a new browser window. For instance, if you typed <A HREF="background.cfm" TARGET="mane">, the file would open in a new browser window called "mane." Using Alphanumeric Characters: As I noted above, frames must be named so that the first character is an alphanumeric character. The designers of HTML have specified several default names that you can use when targeting links. These include:
|
Copyright © 1993-2009 Colorado State University and/or this site's authors, developers, and contributors. Some material displayed on this site is used with permission.