Section 11.8. XFrames


11.8. XFrames

Frames are a rags-to-riches success story. From a nonstandard extension in the Netscape browser to a standard component of HTML and XHTML, frames have proven themselves as a core element of the HTML world. Nonetheless, there are problems with frames that have never been fully resolved:

  • Navigation with a browser's Back button can be unpredictable.

  • You cannot directly reference a document within a frameset.

  • You cannot reference a particular collection of frames with a single URL.

  • Search engines often do not follow framed content.

To correct these deficiencies while retaining the power of frames, the World Wide Web Consortium (W3C) has proposed a slightly different model for framed content. This model is still a working document, and has not yet been implemented in any browser. Still, we briefly describe it here to make authors aware of what they might expect from frames in the near future.

11.8.1. An XFrames Document

Within HTML and XHTML, frames replace the <body> of a document, leaving the <html> and <head> tags intact. In the XFrames model, an XFrames document replaces the entire <html> document, carrying with it its own <head> and framed content. Within the <head> tag, authors can provide a <title> and <style> tags; the framed content is then denoted within < group > and <frame> tags. A short XFrames document might look like this:

 <frames xmlns="http://www.w3.org/2002/06/xframes/">   <head>     <title>Kumquat Lore</title>     <style type="text/css">       #header {height: 10em }       #toc, #nav {width: 20%}       #footer {height: 4em }     </style>   </head>   <group compose="vertical">     <frame xml:id="header" source="lore.xhtml"/>     <group compose="horizontal">       <frame xml:id="toc" source="toc.xhtml"/>       <frame xml:id="main" source="intro.xhtml"/>       <frame xml:id="nav" source="main-nav.xhtml"/>     </group>     <frame xml:id="footer" source="copyright.xhtml"/>   </group> </frames> 

The <head> tag sets the title for the framed document and defines styles that will affect the display of the correspondingly named frames within the document set. The <group> tag, analogous to the <frameset> tag, defines a group of frames and other groups whose layout is controlled by the compose attribute. The <frame> tag defines a single document whose content is displayed within that frame in the document. In this document, five frames are arranged in three rows, with one frame at the top, one at the bottom, and three in the middle row. In that row, the left and right frames each occupy 20 percent of the available space, with the center frame taking up the remainder. Individual frames are named with the xml:id attribute; these names are referenced when loading new content in a frame, when associating styles with a frame, and when creating a URL to display a specific frameset, as described shortly.

The compose attribute in the <group> tag provides some additional layout capabilities that conventional frames do not allow. While the horizontal and vertical layout choices perform the appropriate action, the single and free choices are more interesting. Setting compose to single causes the browser to display only one of the frames in the group at a time, while providing some sort of mechanism to indicate the presence of other frames and a way to select them. One can imagine a pull-down menu that lets the user choose one frame at a time, for example.

The free value for the compose attribute displays the frames in a group as a set of freely movable windows within a display area. The user can move and rearrange the windows as desired, even overlapping them! Presumably, this would allow frames to be displayed in a sort of "desktop" within the browser, completely at the user's discretion.

11.8.2. XFrames URLs

To support explicit reference to frames within a framed document, the XFrames model extends the definition of a URL to include a special #frames keyword. This feature lets you specify the content for each frame in a document, something that is impossible with the current HTML and XHTML frames model.

To use this feature, add the special #frames keyword to the end of a URL referencing a frame document. Follow the keyword with a list of frame IDs and their desired content, all enclosed in parentheses. Sound difficult? It's not:

 http://www.kumquat.com/lore.html#frames(toc=section7.xhtml,main=arctic-quats.xhtml) 

This URL opens the framed document named lore.html , and loads the toc and main frames with the desired pages. The other frames named in the document are loaded with their default content because they are not mentioned in this URL. Frames without default content are left blank.

This powerful syntax has lots of benefits for authors and end users. Authors can now construct links that will open a complete set of framed documents in a specific, repeatable manner. And users can save a bookmark to a framed document, assured that when they return to the document, all the frames will be opened with the same content as when they saved the URL.



HTML & XHTML(c) The definitive guide
Data Networks: Routing, Security, and Performance Optimization
ISBN: 596527322
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Tony Kenyon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net