Nesting and Recursion

By nesting we mean placing a table within a table, or a frameset within a frameset. By recursion we mean "well-defined self-reference" [1].

Nesting of Tables

When nesting tables, you place a table within a cell of another table. In general the nesting of tables is not a good idea. The proper layout for tables is not easy to compute, and the more tables, and the more nest-tables are on a page, the harder that page is to display (and the longer it will take to load).

One use of nested tables is to provide colored borders around tables. One makes tbe background of the "outer" table the border color; the "inner" table is then given another color. An example is demonstrated in this excerpt from the GDGSA main page.

Nesting of Frames

On the previous page several examples of nested frames were given. In tables, a nested table is placed within a table cell; in frames, the nested frameset takes the place of the frame that would normally go there. Furthermore, the src of a frame can be another HTML document containing framesets.

The following examples demonstrate a series of nested frames. There are eleven different examples.

Recursion

A truly recursive frameset would have page A consist of a frameset; each frame on page A would then have src="A", thus referencing A. Ideally, the framed As would also frame A, etc. In most browsers, however, this does not happen, but there are work-arounds to achieve similar results.

The easiest is for page A to have a frameset, and for each frame to call B. B then has a frameset, and the frames call A. In a similar fashion, but so as not to cause infinite recursion, one can simply use a chain of framesets (A calls B, calls C, ... calls Z, and then ends). That is the key behind a series of pages I have titled "Browser Torture."

In a webpage you can write a <meta> tag in the page head that causes the page to reload or load another page. This can be useful for loading a sequence of different pages in a given frame.

Further Examples

  • Example 1: A frameset has two rows: one a frameset, the other a frame; the frameset has two columns (one a frameset, one a frame); etc. The fame that is loaded has a similar structure. The end result is a nice pattern.
  • Example 2: This set of pages has a similar structure, but instead of immediately loading further frameset, the frame cycles through a short sequence of different colored pages (taking advantage of the <meta> meta tag discussed above), and finally loads the original page into the frame (and is therefore a use of nested, recursive frames).
  • Example 3: Here a page is divided into four frames (2x2); each of which loads a red page. The red loads green after several seconds, green loads blue, blue loads black, and black loads red. The cycle continues. This demonstrates the <meta> tag mentioned above. Another version uses two columns and four rows.
  • Example 4: This final example differs from Example 3 only in that the black page now calls the original frameset, making this another recursive-nested frameset.

Be aware that these nested framesets have crashed some browsers.


Contents

Chapter 4

Previous

Next

This site © copyright 1999, Steve Krause, all rights reserved.