My Blog List

Frames

TIP: If you're tempted to use frames in your web site, think long and hard about whether they're really necessary. Don't just do it because it's "new" or "cool"; ask whether they actually improve the navigability of your site rather than detracting from it. While there are a handful of good uses for frames, most actual uses are unnecessary.
Frames are probably the most controversial thing Netscape came up with, back when they were the dominant browser, since the BLINK tag. Many people absolutely hate them. One reason for this is that frames are often misused, with excessive numbers of frames taking screen space away from the main content of a site in order to present unneccessary things like distracting animated ad banners. But even when used carefully, frames have some problems:
  • Users can't bookmark individual pages of your site, as only the URL of the original frameset shows up in the browser. Thus, somebody who finds something interesting buried deeply within a framed site might have trouble getting back there later.
  • Navigation can be difficult and inconsistent. In Netscape 2.0, the BACK button took you all the way past any frames you'd surfed through to the previous site before the frameset, making it really difficult to retrace your path through the site. This was fixed in 3.0, but now you had the reverse problem that if the framed site was full of different frames that keep reloading, an attempt to use the BACK button would retrace all of these and require lots of clicks to get back to the last "real page" you were at.
  • A user with a lower-resolution screen than the designer expected may not have room for all of the frames' contents, and some of the graphical navigation bars may not fit. Sometimes a designer will make such a frame nonscrolling, so when it's too small to fit all the content the user has no way to get to the remainder of it.
  • Since many search engine robots still don't index frames, a framed site may be cutting off most of its content from the indexers. And any indexer that does index frames could send users directly to a frame, and the user following such a link would have no way of finding its full frameset context which might have essential navigation controls not found in the frame itself.
  • If some of the framed pages are on secure servers for online ordering, the user can't tell, as the "key" icon displayed for secure pages only appears when the entire page is secure, not just one frame of it. I'm involved myself in the creation of online commerce sites, and have had to deal with complaints of clients who first insisted on having frames in their site, and then griped about how their customers can't tell their transactions are secure.
Despite all of this, frames do have their uses. Sites that critique other sites, like webpagesthatsuck.com and mcspotlight.org, can make effective use of frames to show the site they're criticizing along with their commentary on it. And sites with interactive content such as online games and real-time chats can find frames to be a useful technique to allow user input in one section of the screen with dynamically-updating status in another; that way, one part can be refreshed with updates without affecting the others. While frames began as a nonstandard Netscape/Microsoft addition to HTML, they are now part of the official HTML 4.0 specification, so they are here to stay. Most sites would, nevertheless, still probably be better without them.
And use of frames might just be a patent violation... at least, that's what Southwestern Bell is claiming, saying that use of frames (or keeping a navigation menu in the same place on all your pages in any other way) violates their patent on this concept. See this discussion. If anyone actually stands up to them in court, however, it's almost certain to be invalidated due to a huge quantity of prior art.

Supporting Non-Framed Users

TIP: If you do use frames, be sure to include a <NOFRAMES> section for the sake of non-frame browsers and search-engine robots.
If you use frames, you should have a NOFRAMES section to support non-framed users, including the search engine robots. This consists of a section of code, within the <FRAMESET> and beneath all the <FRAME>s, starting with <NOFRAMES> and ending with </NOFRAMES>. Within these tags should go a <BODY> block containing the content to be displayed by browsers that don't support frames (or when the user has disabled the use of frames, if that option is provided).
Some critics have remarked that the need for the NOFRAMES tag is dubious, since frame-supporting browsers will ignore any HTML code in the main frameset page other than the frame definitions, and non-frame-supporting browsers will ignore all the frame definitions and use the remaining HTML code whether or not the NOFRAMES tag is present. Thus, there's no reason not to go straight to the BODY tag right after the frameset, without having to explicitly code that this is for "<NOFRAMES>" use. Maybe so, but including NOFRAMES explicitly does provide a clear indication of the purpose of the code being enclosed in that block, and with future HTML revisions likely to introduce added complexities of inline frames, it's best to put this explicit code in place to remove all possible ambiguity later. Anyway, the HTML 4.0 specs say to include this tag.
NOTE: NOFRAMES would have been more useful if it were implemented such that any section of content within such an element, anywhere in any document, would be ignored when the document is being displayed as part of a frameset. In that case, you could provide alternative navigation within individual frames that would show up when the page was viewed separately but not when it's in a frame. In fact, Microsoft Internet Explorer implemented NOFRAMES this way, but Netscape didn't, so this use of the element becomes yet another browser-specific thing to be avoided due to its inconsistent effect. But it's perfectly safe to use NOFRAMES in its original usage, within the frameset document.
Hopefully, your NOFRAMES section will contain all of the content and functionality of your main framed site, not just a curt note that you can't do anything unless you upgrade your browser. You can make the no-frames index a separate page, and have a link to it both within the NOFRAMES code and also on the main navigation frame, for the sake of users who just don't like frames.
If you fail to use a meaningful NOFRAMES section, you may be cheating your site out of a good search engine listing; some search engines don't index frames, so all they might see is the part in the main index file. Try searching in popular search engines for the string "This site requires frames. Your browser doesn't support them", and be amazed at how many sites have this as their description as far as the robots are concerned. Don't make your site fall into this category. Use a NOFRAMES section, as well as a good TITLE and META tags in the main index file (it's astounding how many developers forget to include these at all in the main frameset document, even after placing them carefully in all other HTML files of the site, which the robots might never see). (But don't use the NOFRAMES section to spamdex with heaps of keywords; that's yet another self-defeating technique that will make things harder on honest Web developers as it leads search engines to discount the NOFRAMES section.)

Use Care in Naming Frames

TIP: Be careful to give frames names that are likely to stay unique, even when a framed page is loaded within a frame of another page.
Targeted links in a framed site reference a frame by its name. These names must be unique. If you give your frames really generic names like "main" and "contents", there's a chance that there will end up being more than one frame of that name on the user's screen, especially if a framed page is loaded within another frameset. This may cause linked pages to show up in unexpected places on the user's screen. Avoid this by giving your frames more unique names, like "dan_main" and "dan_contents" instead of just "main" and "contents".
Also, try to make the names meaningful to users; some specialized browsers (such as text-mode and speaking browsers) which don't present frames in a normal visual manner will present the names of the frames either alongside their content or as links to their content. So use names that make some sense and give some idea of their contents or purpose, not just "frame1" and "frame2".

More Frame Cautions

  • Don't forget to close the frameset with </FRAMESET>. If you have several nested framesets, close all of them. If you forget, some browsers might get confused and show a blank page instead of your frameset. (In particular, Netscape tends to be more finicky about this than Internet Explorer, as it is with requiring <TABLE> elements to be closed.)
  • Don't precede the frameset with a <BODY> tag or any content (such as plain text or HTML tags like <P>) which belongs only within a page's body. This sort of content belongs only within the <NOFRAMES> section. If it's found elsewhere on a frameset page, some browsers (once again, most notably Netscape) will get confused and fail to show the frames. Your frameset page should consist of a <HEAD> section with a title and optional <META> tags, then the <FRAMESET>, ending with the <NOFRAMES> section (which contains a <BODY> tag). Don't change the order of these elements.

Breaking Out of Frames

One of the most annoying things you can do on a framed site is to link to somebody else's site and keep part of your site present in a frame. That way, the user never does escape you, and none of the other sites are bookmarkable as long as yours is stuck as the main frameset. Even worse, if the destination site uses frames too, you wind up with frames within frames until there's barely any space for actual content. (If you eventually reach a link that goes back to the original site, you might even wind up with a recursive page containing multiple nested copies of the same frame; this can go on infinitely if you keep following the links!) You may think this is a clever marketing scheme to keep users from leaving your site permanently, but it may just get them so ticked off at you they never return.
Avoid this by making all your external links have TARGET="_top" within the <A HREF="..."> tag. These target attributes are case-sensitive, so remember to type "top" in all lower case, and precede it with an underscore.
TIP: If another web site links to yours within a frame, you can give users a chance to escape by adding this link prominently on your page:
<A HREF="./" TARGET="_top">Are You Framed? Escape Now!</A>
If it happens that somebody has framed this site, here's a link to get out!

Hall of Shame

Make your site better by looking at other sites that show, by example, what not to do!
NOTE: The inclusion of a site in my "Hall of Shame" links should not be construed as any sort of personal attack on the site's creator, who may be a really great person, or even an attack on the linked Web site as a whole, which may be a source of really great information and/or entertainment. Rather, it is simply to highlight specific features (intentional or accidental) of the linked sites which cause problems that could have been avoided by better design. If you find one of your sites is linked here, don't get offended; improve your site so that I'll have to take down the link!
  • If you try to bring up content from this page outside the frameset, like by right-clicking on the main frame (so you can see it in a full browser window without the other junk, or get a direct URL to link or bookmark), it triggers JavaScript code that puts it right back into the frameset again. Very annoying.
  • A page of child care statistics put up by the Anchorage Department of Health and Human Services (Alaska) has, inexplicably, as its <TITLE>, "This web page uses frames, but your browser doesn't support them". The META tag indicating what program created it says "Microsoft Word 97," so I guess that program generates titles by "abstracting" the page content, and the only page content it could find was that dopey "no-frames" section.

No comments:

Related Posts Plugin for WordPress, Blogger...