Contents
This section is NOT PART OF XHTML 2.
As its name suggests, the Frames Module provides frame-related elements. Specifically, the Frames Module supports:
Elements | Attributes | Minimal Content Model |
---|---|---|
frameset | Core, cols ( MultiLength), rows ( MultiLength) | (frameset | frame)+, noframes? |
frame | Core, frameborder ("1" | "0"), longdesc ( URI), marginheight ( Pixels), marginwidth ( Pixels), noresize ("noresize"), scrolling ("yes" | "no" | "auto"*), src ( URI) | EMPTY |
noframes | Common | body |
When this module is selected, the minimal content model of the
html
element of the Document Module is changed to (head,
frameset)
.
Implementations: DTD, XML Schema
The frameset element specifies the layout of the main user window in terms of rectangular subspaces.
Attributes
Setting the rows attribute defines the number of horizontal subspaces in a frameset. Setting the cols attribute defines the number of vertical subspaces. Both attributes may be set simultaneously to create a grid.
If the rows attribute is not set, each column extends the entire length of the page. If the cols attribute is not set, each row extends the entire width of the page. If neither attribute is set, the frame takes up exactly the size of the page.
Frames are created left-to-right for columns and top-to-bottom for rows. When both attributes are specified, views are created left-to-right in the top row, left-to-right in the second row, etc.
The first example divides the screen vertically in two (i.e., creates a top half and a bottom half).
<frameset rows="50%, 50%"> ...the rest of the definition... </frameset>
The next example creates three columns: the second has a fixed width of 250 pixels (useful, for example, to hold an image with a known size). The first receives 25% of the remaining space and the third 75% of the remaining space.
<frameset cols="1*,250,3*"> ...the rest of the definition... </frameset>
The next example creates a 2x3 grid of subspaces.
<frameset rows="30%,70%" cols="33%,34%,33%"> ...the rest of the definition... </frameset>
For the next example, suppose the browser window is currently 1000 pixels high. The first view is allotted 30% of the total height (300 pixels). The second view is specified to be exactly 400 pixels high. This leaves 300 pixels to be divided between the other two frames. The fourth frame's height is specified as "2*", so it is twice as high as the third frame, whose height is only "*" (equivalent to 1*). Therefore the third frame will be 100 pixels high and the fourth will be 200 pixels high.
<frameset rows="30%,400,*,2*"> ...the rest of the definition... </frameset>
Absolute lengths that do not sum to 100% of the real available space should be adjusted by the user agent. When underspecified, remaining space should be allotted proportionally to each view. When overspecified, each view should be reduced according to its specified proportion of the total space.
Framesets may be nested to any level.
In the following example, the outer frameset divides the available space into three equal columns. The inner frameset then divides the second area into two rows of unequal height.
<frameset cols="33%, 33%, 34%"> ...contents of first frame... <frameset rows="40%, 50%"> ...contents of second frame, first row... ...contents of second frame, second row... </frameset> ...contents of third frame... </frameset>
Authors may share data among several frames by including this data via an object element. Authors should include the object element in the HEAD element of a frameset document and name it with the id attribute. Any document that is the contents of a frame in the frameset may refer to this identifier.
The following example illustrates how a script might refer to an object element defined for an entire frameset:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <title>This is a frameset with object in the head</title> <!-- This object is not rendered! --> <object id="myobject" data="data.bar"></object> </head> <frameset> <frame src="bianca.html" name="bianca"> </frameset> </html> <!-- In bianca.html --> <html> <head> <title>Bianca's page</title> </head> <body> ...the beginning of the document... <p> <script type="text/javascript"> parent.myobject.myproperty </script> ...the rest of the document... </body> </html>
The frame element defines the contents and appearance of a single frame.
Attributes
What happens if the src fails
If the src attribute target is not available, the contents of the element are processed. Is there a DOM event that is raised in this context as well?
At the Dulles f2f we discussed the possibility of relying upon DOM events to raise these - but ensure that XHTML refers to DOM events for any elements / attributes that have behaviors in addition to semantics.
The src attribute specifies the initial document the frame will contain.
The following example HTML document:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <HTML> <HEAD> <TITLE>A frameset document</TITLE> </HEAD> <FRAMESET cols="33%,33%,33%"> <FRAMESET rows="*,200"> <FRAME src="contents_of_frame1.html"> <FRAME src="contents_of_frame2.gif"> </FRAMESET> <FRAME src="contents_of_frame3.html"> <FRAME src="contents_of_frame4.html"> </FRAMESET> </HTML>
should create a frame layout something like this:
------------------------------------------ |Frame 1 |Frame 3 |Frame 4 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------| | | |Frame 2 | | | | | | | | | | | ------------------------------------------
and cause the user agent to load each file into a separate view.
The contents of a frame must not be in the same document as the frame's definition.
ILLEGAL EXAMPLE:
The following frameset definition is not legal HTML since the contents of the second frame are in the same document as the frameset.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <HTML> <HEAD> <TITLE>A frameset document</TITLE> </HEAD> <FRAMESET cols="50%,50%"> <FRAME src="contents_of_frame1.html"> <FRAME src="#anchor_in_same_document"> <NOFRAMES> ...some text... <H2><A name="anchor_in_same_document">Important section</A></H2> ...some text... </NOFRAMES> </FRAMESET> </HTML>
The following example illustrates the usage of the decorative FRAME attributes. We specify that frame 1 will allow no scroll bars. Frame 2 will leave white space around its contents (initially, an image file) and the frame will not be resizeable. No border will be drawn between frames 3 and 4. Borders will be drawn (by default) between frames 1, 2, and 3.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <HTML> <HEAD> <TITLE>A frameset document</TITLE> </HEAD> <FRAMESET cols="33%,33%,33%"> <FRAMESET rows="*,200"> <FRAME src="contents_of_frame1.html" scrolling="no"> <FRAME src="contents_of_frame2.gif" marginwidth="10" marginheight="15" noresize> </FRAMESET> <FRAME src="contents_of_frame3.html" frameborder="0"> <FRAME src="contents_of_frame4.html" frameborder="0"> </FRAMESET> </HTML>
The @longdesc attribute allows authors to make frame documents more accessible to people using non-visual user agents. This attribute designates a resource that provides a long description of the frame. Authors should note that long descriptions associated with frames are attached to the frame, not the frame's contents. Since the contents may vary over time, the initial long description is likely to become inappropriate for the frame's later contents. In particular, authors should not include an image as the sole content of a frame.
The following frameset document describes two frames. The left frame contains a table of contents and the right frame initially contains an image of an ostrich:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <HTML> <HEAD> <TITLE>A poorly-designed frameset document</TITLE> </HEAD> <FRAMESET cols="20%, 80%"> <FRAME src="table_of_contents.html"> <FRAME src="ostrich.gif" longdesc="ostrich-desc.html"> </FRAMESET> </HTML>
Note that the image has been included in the frame independently of any HTML element, so the author has no means of specifying alternate text other than via the @longdesc attribute. If the contents of the right frame change (e.g., the user selects a rattlesnake from the table of contents), users will have no textual access to the frame's new content.
Thus, authors should not put an image directly in a frame. Instead, the image should be specified in a separate HTML document, and therein annotated with the appropriate alternate text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <HTML> <HEAD> <TITLE>A well-designed frameset document</TITLE> </HEAD> <FRAMESET cols="20%, 80%"> <FRAME src="table_of_contents.html"> <FRAME src="ostrich-container.html"> </FRAMESET> </HTML>
<!-- In ostrich-container.html: --> <HTML> <HEAD> <TITLE>The fast and powerful ostrich</TITLE> </HEAD> <P> <OBJECT data="ostrich.gif" type="image/gif"> These ostriches sure taste good! </OBJECT> </HTML>
The noframes element specifies content that should be displayed only by user agents that do not support frames or are configured not to display frames. User agents that support frames must only display the contents of a noframes declaration when configured not to display frames. User agents that do not support frames must display the contents of noframes in any case.
Attributes
For example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <HTML> <HEAD> <TITLE>A frameset document with NOFRAMES</TITLE> </HEAD> <FRAMESET cols="50%, 50%"> <FRAME src="main.html"> <FRAME src="table_of_contents.html"> <NOFRAMES> <P>Here is the <A href="main-noframes.html"> non-frame based version of the document.</A> </NOFRAMES> </FRAMESET> </HTML>
noframes may be used, for example, in a document that is the source of a frame and that uses the transitional DTD. This allows authors to explain the document's purpose in cases when it is viewed out of the frameset or with a user agent that doesn't support frames.