|

Proper Use Of Frames
This web site makes extensive use of the frames extension to HTML. Frames
were first implemented in April of 1996, were used for about 3 months, and then
were generally abandoned as being impractical.
Frames offer many advantages, and through careful application, their
disadvantages can be circumvented.
- Problems With Frames
- Advantages Of Frames
- Frame Technical Information
- Troubleshooting Frames
Problems With Frames
Frames, if not done correctly, present numerous usability problems. All of
these problems can be solved by using the TARGET=_top attribute for the <A>
tag.
The first usability problem is that many framed sites render your browser's
back button useless. This is caused by failing to use the TARGET="_top"
attribute in any outbound links. If this isn't done, any frames in the site
that you look at will not be recorded by the history file in your browser --
only the first page of the site that you looked at will be stored.
The second problem that frames cause is an outgrowth of the first. Because
calling up documents in frames doesn't change the URL of the document, you can't
bookmark any pages at a framed site, except the first one that you see. This
can cause incredible amounts of user frustration.
The third problem is that frames require strange clicking patterns to use
links in the "expected" way. Most users don't think about whether
they need to click and hold, or right-click a link, they just click it. If
they're in a framed document, and are clicking on a link to a document that's at
another site that doesn't use frames, or worse yet, uses a different set of
frames, that document will appear in the selected frame of the document they're
trying to get out of. This can be extremely confusing to users.
All of these problems can be solved by using the
TARGET=_top attribute for the <A> tag.
Advantages Of Frames
The first advantage of frames is usability. This site uses frames to keep a
navigational tool handy at all times for the end user. Another use of frames is
to show a pair of documents that need to be compared at different points, as CNN
did for their political coverage. This is also useful for showing revisions
between drafts on an intranet project.
The second advantage of frames relies on the use of the <NOFRAMES>
tags. <NOFRAMES> can be used to simply put a links to the SRC document
called for in the <FRAME> tags, but this is, ultimately, tacky.
A better use for the space created by the <NOFRAMES> tag is to put a
duplicate copy of the document called for in the primary viewing area of the
document. This way, a user with a non-frames capable browser will never know
the frames are there, making the transition completely transparent. It's
important to keep both versions of the document exactly in synch.
For example, each page on this web site has two files, named <document
name>.html and <document name>_main.html. This file is style2.html and
style2_main.html, for example. The file style2.html has the frameset
attributes, and the text you're reading now stored in the NOFRAMES tags. The
file style2_main.html just has the text you're reading. Keeping two copies of
the documents is more work, but the increase in navigability without burning
bridges to older browsers is worth it.
Keeping two copies of the documents is more work, but
the increase in navigability without burning bridges to older browsers is worth
it.
Another useful trick gained from using frames is the ability to keep two
distinct versions of a document. For example, many older browsers can't handle
tables or image maps. By putting the non-tables source in the <NOFRAMES>
space, you can exploit the fact that any browser that can't see tables can't see
frames either, avoid frustrating users. An example of this technique is used in
the schedule for upcoming
games on this website.
As a parenthetical comment, using this technique as a way to avoid putting a
link list under a server-side image map is not recommended. Many users operate
with their graphics display options turned off to increase speed.
Frame Technical Information
Frames require the following HTML tags:
- <FRAMESET>
- <FRAME>
- <NOFRAMES>
- <A>
The <FRAMESET> tag tells the browser that
there are frames on this web page. Attributes used with the tags define how
the browser window will be divided. This document defines the frames as
collumns, and sets the first (left-hand) collumn at 80% of the browser window,
and the second (right-hand) collumn at 20% of the browser window.
The<FRAME> tag needs to be used for each of the
collumns or rows used by the document. The SRC attribute of this tag defines
which document is pulled up into the frame. The document pulled up by the SRC
attribute of the <FRAME> tag cannot have the <FRAMESET> tags in it.
Because the <FRAME> SRC attribute pulls up a different document from the
one that the browser is actually viewing, several avenues for confusion can
result, and several advantages can be exploited.
Because of the use of the TARGET attribute used in the <A> tag, it's a
good idea to use the NAME attribute in the <FRAME> tag to name the
frames. The large frame is named "Main", and the smaller frame is
named "Sidebar" on all of the documents of this web site.
This web site uses the convention of naming the source document <filename>.html,
and the source document as <filename>_main.html. Thus, this document is
style2.html. The SRC pulled up into the Main frame by the <FRAME> tag is
style2_main.html. The sidebar never changes and is named
navigation_sidebar.html.
Because the <FRAME> SRC attribute pulls up a
different document from the one that the browser is actually viewing, several
avenues for confusion can result, and several advantages can be exploited.
The next tag used to implement frames is the <NOFRAMES>
tag. The <NOFRAMES> tag encapsulates the <BODY> element of the HTML
document. What this allows you to do is enter content that will be seen by
browsers that can't resolve frames. This allows you some unexpected flexibility
with frames documents.
The last tag used for frames is the <A> tag, or,
more specifically, the TARGET attribute added to it. There are two ways to use
the TARGET attribute with frames. The first is to target a frame that's been
named using the NAME attribute of the <FRAME> tag. Thus, you could target
a link to the main frame of a document, and clicking on that link will pull that
document up in the main frame. This is particularly useful if you want to
ensure that the document always appears in the appropriate frame.
The second way to use the TARGET attribute is the most important. There are
four special strings that can be used with the TARGET parameter:
_self, _top,
_blank, and
_parent.
_self will open the new document in the frame that the
current document is in. This can cause problems if the new document also has a
<FRAMESET>, as it will further subdivide the current browser window. I
have yet to find a use for this string.
_top is the single most important TARGET that you can
use for your links. _top tells the browser to look for the <FRAMESET> of
the new document and use it instead of the one in the document you're currently
in. Any link that goes to a page outside of your site should have _top as the
TARGET.
_blank will open up a new browser window for pages
hit with that link. This is useful in several contexts, such as pages that are
meant to compare two things, or to provide a quick reference. There is
currently no target you can put on a link that will close a browser
session, which makes this one tricky to use. (If you have five links with this
target, and someone visits all five links, they'll end up with six browser
sessions running, which can crash some systems.)
_parent will tell your browser to condense the <FRAMESET>
of the current document to one frame, and to open the new document there. In
general, _top is a safer bet.
Any link that goes to a page outside of your site
should have _top as the target.
This web site uses _top as the default target on all links, with two
exceptions:
Links that are internal to a page (such as the ones from the table of
contents at the top of this document to the subject headers). Internal links
are targeted to Main to avoid the annoyances of reloading the document
constantly.
Links that go to named targets in different documents are TARGETed to Main
as well. Note that you will need to point the HREF in this instance to the
corresponding document in the pair. For example, a link to fozbot.html from
frobozz.html would also need a link to fozbot_main.html from frobozz_main.html.
Troubleshooting Frames
- I copied one of the documents to use as a template. Now, when I try
loading it to test it, the new document that I made only displays the one that I
was originally using as a template.
- This is caused by not updating the FRAME SRC attribute in the <FRAMESET>
tag. Make sure that it's pointing to <newdocument>_main.html, not <olddocument>_main.html.
(This one caught me for two days before I remembered it.) While you're at it,
make sure that the document title attribute in the <HEAD> tag is accurate.
- When I test the new frames document, I get the sidebar repeated twice.
If I jump back, and then go back to it, the sidebar gets repeated multiple
times. What gives?
- This is caused by forgetting to put _top as the TARGET of the link.
- When I put in a named link to a named target that's not in the same
document, such as going from document1.html to document2.html#magic, the link
only pulls up the top of the page.
- You'll need to put a link from document1_main.html to
document2_main.html#magic, setting the TARGET to Main.
Problems with the page? Email Ken
Burnside. |