Frames

Using frames, the screen is divided into areas, with each area possibly displaying a different document, each one scrolled independently. Among other uses, frames facilitate the use of table of contents and button bars that do not vanish as the user scrolls down the main document:

A frame-based document replaces the Body element with a Frameset element:

<HTML>
<HEAD>...</HEAD>
<FRAMESET>...</FRAMESET>
</HTML>

The Frameset element defines an area that generally fills the end user's screen. This area is divided into frames using the Cols or Rows attribute. These attributes take a value that specifies the width or height of the sub-areas. This value specifies the height or width using one of three methods, namely the number of pixels (not advised), proportion or percentage of the available space. Values are separated by commas, which also therefore implicitly specify the number of columns or rows in the set:

<FRAMESET ROWS="1500, 1000, 500">

<FRAMESET ROWS="3*, 2*, *">

<FRAMESET ROWS="50%, 33%, 16%">

The first example above specifies a height of 1,500 pixels for the first row, the second example reserves three proportional units for the first row (the asterisk character alone is equivalent to '1*'), and the third example specifies that the first row should occupy half the available height ('50%'). If the available height were 3,000 pixels, then all three examples above would be equivalent. These value types may be mixed:

<FRAMSET COLS="50%, 100, 2*, *">

When value types are mixed, fixed values have precedence, followed by percentage values, and then proportional values. In the example above, the second column is assigned exactly 100 pixels of horizontal space, the first column is then assigned half of the remaining space, and the remainder is divided among the proportional columns (the third column taking twice the space of the last column):

2nd (percentage) priority 1st priority 3rd (proportional) priority
50% of remaining area 100 pixels 2* 1*

A Frame Set can contain further embedded Frame Sets. Each embedded Frame Set occupies the space reserved for it by the enclosing Frame Set. Taking the example above, a Frame Set embedded in the first column is restricted to the left half of the screen and will define subdivisions of this area:

<FRAMESET COLS="50%, 100, 2*, *">
   <FRAMESET COLS="60%, 40%">
   ...
   </FRAMESET>
   ...
</FRAMSET>

|-------- 60 % -------|--- 40 % ---| 100 pixels 2* 1*

A Frame Set may contain a Noframes element. This element is intended to hold information to be displayed by a browser that cannot interpret the frames. Its function is therefore similar to the Alt attribute in the Image element. Its content, which may include normal blocks such as paragraphs and lists, is not displayed in frames-aware browsers:

<NOFRAMES>
<P>If you CAN see this, then you can NOT see the Frames!
</NOFRAMES>

A frames-aware browser ignores this tag and all its contents. A browser that does not understand frames will not be aware of the Noframes element, but is most likely to remove the tags, while leaving the enclosed text intact for presentation to the user.

Finally, a Frameset element may contain a Frame element. This is an empty element, so has no end-tag. It is used to identify the document to be displayed within the frame, to identify the frame itself (so that it can be made the target of links from other frames or documents), to determine whether the width and height of the frame can be altered by the end user, to determine whether scroll-bars are used, and to specify margin widths. The Frame element has a Source attribute (Src) which contains the URL of the HTML document to be displayed in the frame. If no URL is provided, the area is left blank. The Frame element also has a Name attribute, which contains the name of the frame, so that it can be the target of a link from another frame or from another document:

<FRAME NAME="main" SRC="../areas/myarea.html">

By referring to the Name value of another frame, a new document can be requested, and displayed in that other area. This feature is ideal for changing the content of the main window as items are selected in a table of contents frame. The A (Anchor) element has a new Target attribute to refer to the actual frame in which the content should be displayed:

The Frame element also has a Scrolling attribute, which indicates whether horizontal and vertical scroll-bars are always present, present as required (when the height or width of the page exceeds the space provided on the screen), or never present. A value of 'yes' forces scroll-bars to appear even if not needed. A value of 'auto' displays scroll-bars when necessary and is the default value. A value of 'no' disables scroll-bars entirely.

The Frame element also has a Noresize attribute, which, if present, prevents the end user from changing the height or width of the frame. By default it is absent, and resizing is allowed. In XML terms, this must be seen as an attribute called Noresize that has an optional, single value of 'NORESIZE', and that minimization is in use to avoid stating the attribute name:

<FRAME SRC="../areas/myarea.html" NORESIZE>

Finally, the Frame element has Marginwidth and Marginheight attributes, which specify the space to reserve between the borders of the frame and the enclosed text. Width settings affect the space between the left and right edges. Height settings affect the space above and below the content. Values are in pixels and, if present, must be at least '1' and not so large that content cannot be displayed; if absent, the browser provides default settings.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset