Tutorial 15: You've been Framed, Part II - HTML with Style | 6 | WebReference

Tutorial 15: You've been Framed, Part II - HTML with Style | 6

index123456

Tutorial 15: You've been Framed, Part II

The nested frameset trick

One trick often used by Web authors the world over is having more than one frameset when usually one would suffice. For instance, take the example above with the large document that contains sections and sub-sections; the frameset could be altered to something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"
 "https://www.w3.org/TR/REC-html40/frameset.dtd">
<HTML>
<HEAD><TITLE>M.O.R.O.N.S. White Paper</TITLE></HEAD>
<FRAMESET ROWS="20%,*">
 <FRAME NAME="toc" SRC="toc.html">
 <FRAME NAME="subsection" SRC="sub1.html">
</FRAMESET>
</HTML>

Now you've got the short table of contents along the top, and a document called sub1.html beneath that. You can make this document a frameset that contains the other two frames needed for our layout, as they should appear for section 1. Following the links in the top frame will take viewers to the frames that corresponds to the section they selected by loading a new frameset.

This approach solves the problem of changing the contents of more than one frame at a time, and also partially solves the linking problem as you can now link to a specific section in your document (but you still can't link to a sepcific sub-section, or a fragment of a sub-section). Search engines will still erroneously link to pages on your site, and most browsers will still bookmark only the initial state of the frameset. Also, note that you've added even more documents to download since every time a user loads a new section he has to load three new documents.

The multiple frameset trick

Refining the above method a bit, you can have each and every document on your site to be a unique frameset, and always use the _top target to load the frameset anew when a viewer follows a link. Now you can change as many frames as you want at a time, and you can link to any page in your document, and have users bookmark it correctly. Using a BASE element can also diminish the chance of accidentally trapping the user in your frameset.

On the down side, you've just added a considerable size overhead to your pages, as users have to download a frameset and at least one (but usually more) frames every time they follow a link. Search engines will still get it all wrong, and you still can't use fragment identifiers for links.

Using Client-Side Scripting

A number of people will tell you that you can use client-side methods such as JavaScript to correct the various problems with frames by havign scripts that do things such as load new pages in frames and various other neat tricks. However, you need to remember a couple of things about scripting. Using scripts as an integral part of your Web site's functionality is a very bad idea. Scripting languages are very unstable, poorly implemented things and have huge incompatibilities between browsers. Many browsers do not support any scripting whatsoever, and many users elect to disable scripting for reasons of security or performance. Scripts are nice if you want to add special effects to spice up a page, but you should avoid using them for anything that is integral to your page; in other words, your site should work properly without the scripts.

index123456

URL: https://www.webreference.com/html/tutorial15/5.html

Produced by Stephanos Piperoglou
Created: May 28, 1998
Revised: February 25, 1999