350:465 Frames Tutorial, October 22, 2001
(corrected and revised Oct 24 -- see Addenda).

    BACKGROUND

  1. Just as TABLES can divide a file into two or more separate areas, so FRAMES can divide the screen into two or more separate files.

  2. The FRAMES areas are either horizontal rectangles (ROWS) or vertical rectangles (COLS). These areas can be defined as pixels, percentages, or by the asterisk wildcard.

  3. A FRAMES set requires three or more files:

    • the FRAMESET structure
    • the first FRAME content
    • the second FRAME content...

    PREPARATION

  4. To create today's demonstration, create the following files, each named after its visible color.

    Hint 1: Save the first file with CTRL-O in Pico and then change the color words and save it as the secodn file, etc.

    Hint 2: For demonstration purposes, skip the full regular file structure and include only the BODY tag and the data content:

    FilenameBODY tagData Content
    white.html<BODY BGCOLOR=white>This is white
    yellow.html<BODY BGCOLOR=yellow>This is yellow
    tan.html<BODY BGCOLOR=tan>This is tan
    ivory.html<BODY BGCOLOR=ivory>This is ivory
    red.html<BODY BGCOLOR=red>This is red
    gray.html<BODY BGCOLOR=gray>This is gray

  5. Create in Pico a menu file called menu1.html with links to each of the color files, using the actual color names:

      <Li> <A HREF="{colorname}.html"> {Colorname} </a> ... etc.

  6. In your browser bring up menu1.html and confirm that each of the six color files displays correctly.

    THE DEMO

  7. In Pico create frames1.html, a FRAMESET file of two rows.

    Note: frameset files do not have a BODY. The HEAD is usually added (you may skip it here)

      <FRAMESET rows="50%,50%">

        <FRAME SRC = "white.html">
        <FRAME SRC = "yellow.html">
      </FRAMESET>

  8. Load frames1.html in your browser.

  9. In Pico open frames1.html and change rows to cols with the following values, adding a third FRAME SRC, changing the colors, and saving the result as frames2.html.

      <FRAMESET COLS="50%,25%,25%">
        <FRAME SRC="white.html">
        <FRAME SRC="gray.html">
        <FRAME SRC="tan.html">
      </FRAMESET>

  10. When complete, load frames2.html in your browser.

  11. In Pico open frames2.html and make the following changes, saving the result as frames3.html. Now there should be two "cols" values, 25% and 75%; the SRC files should be menu2.html and white.html; and there should be a NAME attribute as shown for each of these files.

    The values "left" and "right" are arbitrary; they could also be called "nav" and "display" or "menu" and "data," etc. Once these frames are named they can be targetted, as in the next instruction.

      <FRAMESET COLS="25%,75%">
        <FRAME SRC="menu2.html" NAME="left">
        <FRAME SRC="white.html" NAME="right">
      </FRAMESET>

  12. In Pico reload menu1.html and make the following changes, adding a TARGET value of "right" to correspond to the previous NAME value, saving the result as menu2.html.

      <li><A HREF="white.html" target="right">white</a>
      <li><A HREF="yellow.html" target="right">yellow</a>
      <li><A HREF="tan.html" target="right">tan</a>
      <li><A HREF="ivory.html" target="right">ivory</a>
      <li><A HREF="red.html" target="right">red</a>
      <li><A HREF="gray.html" target="right">gray</a>

  13. When ready, load and test frames3.html in your browser.

    FUTURES

  14. FRAMESETS can combine rows and cols.

  15. FRAMESETS can call other framesets: the main frames menu (example US and its states) can call submenus (example a state and its cities), etc.

  16. FRAMESETS can bring up a combination of areas -- example, static logo at top and help at bottom with dynamic menu at left and data area at right

  17. ADDENDA 1 -- Borders, margins, spacing (October 24, 2001):

    • A full set of FRAMESET and FRAME commands is available to control frame borders, margins, and spacing (similar to these attributes in TABLES)

    • FRAMESET attributes apply to the entire screen while FRAME attributes apply to just one FRAME (and sometimes its adjacent neighbor).

      Frameset AttributeDefaultother valuesComment
      BORDER50-nsee FRAMEBORDER
      BORDERCOLOR-any 
      FRAMEBORDER-anyif 0, use with BORDER=0
      FRAMESPACING-anylike BORDER, I.E. only
      MARGINWIDTH80-nsides internal spacing
      MARGINHEIGHT80-ntop/bottom internal spacing
      SCROLLINGautoyes, noscrollbars?
      NORESIZE-NORESIZEwindow size
      TARGET-NAME valueas in FRAMESET
      TARGET-"_top"replaces entire window
      TARGET-"_blank"adds new window
      TARGET-"_self"replaces this FRAME
      NOFRAMES-NOFRAMES tag pair, alt. text

  18. ADDENDA 2: IFRAME: inline frame

    IFRAMES are useful as inline frames within other pages (like tables) but with their own borders and scrollbars. IFRAMES are "inline" elements which fall within the text flow, unlike TABLEs, which are "block" elements which have separate placement attributes.

    Since the IFRAME inserts the contents of a SRC "url," multiple uses can be made of that SRC "url" (just as an image can be reused). For example, a list of links which is constantly updated and which is referenced in several places can be kept in a single source file both visible on its own and also inserted as an inline frame (IFRAME) in other files. Other uses are help files, reading bibliographies, to-do lists, signature blocks, etc. The IFRAME can also show just a sample of a longer file which can be scrolled. The IFRAME does not use a separate FRAMESET file. Here are the attributes of the IFRAME tag:

    • IFRAME SRC={url}
    • NAME="{name}"
    • WIDTH=x HEIGHT=y
    • ALIGN=LEFT or RIGHT (for following text)
    • /IFRAME closing tag -- essential!
    • other attributes: FRAMEBORDER, HSPACE/VSPACE, SCROLLING, MARGINWIDTH/MARGINHEIGHT (see above)
    • Note: The IFRAME is not supported by Netscape 4

  19. ADDENDA 3 -- Wildcard variable (*) correction

    The size of Frame elements may be specified by percentages (50%), pixels (200), or the wildcard variable (*). Multiples of the wildcard variable are expressed as "2*", "3*", etc, not "**", "***", etc.

PROBLEMS

Some problems in working with multiple frames:

REVIEW

Files created:


FRAMES DEMOS -- LINKS

SEE CASTRO, CHAPTER 10: LESSONS/EXERCISES