frame Creating Individual Frames

<frame> Creating Individual Frames

You use the <frame> element to create an individual frame. This element is an empty element, and you use it inside the <frameset> element. It's supported in XHTML 1.0 Frameset only. Here are its attributes:

  • class Gives the style class of the element. (XHTML 1.0 Frameset.)

  • dir Sets the direction of text that doesn't have an inherent direction in which you should read it, called directionally neutral text. You can set this attribute to ltr , for left-to-right text, or rtl , for right-to-left text. (XHTML 1.0 Frameset.)

  • frameborder Sets whether borders enclose the frame. In Netscape Navigator, you set this attribute to yes (the default) or no ; in the Internet Explorer you set it to 1 (the default) or (no border). (XHTML 1.0 Frameset.)

  • id Refer to the element; set this attribute to a unique identifier. (XHTML 1.0 Frameset.)

  • lang Specifies the base language used in the element. Applies only when the document is interpreted as HTML. (XHTML 1.0 Frameset.)

  • longdesc Specifies the URI for a long description of the frame contents, which may include markup. (XHTML 1.0 Frameset.)

  • marginheight Sets the height of the top and bottom margins used in the frame. (XHTML 1.0 Frameset.)

  • marginwidth Sets the width of the right and left margins used in the frame. (XHTML 1.0 Frameset.)

  • name Sets the name of the frame, which you can use as a target destination for <a> , <area> , <base> , and <form> elements. (XHTML 1.0 Frameset.)

  • noresize Indicates that the frame may not be resized. The default is that frames may be resized by dragging the border. (XHTML 1.0 Frameset.)

  • scrolling Sets scrollbar action. Possible values are auto , yes , and no . (XHTML 1.0 Frameset.)

  • src Required. Holds the URI of the frame document. (XHTML 1.0 Frameset.)

  • style Inline style indicating how to display the element. (XHTML 1.0 Frameset.)

  • title Contains the title of the element. (XHTML 1.0 Frameset.)

  • xml:lang Specifies the base language for the element when the document is interpreted as an XML document. (XHTML 1.0 Frameset.)

This element does not support any XHTML events.

You can use the <frame> element inside a <frameset> element to create a frame. This element exists so that you can specify the document that is displayed in a URI. That's the one required attribute in this element: src , which holds the URI of the document the frame is to display.

For example, here's how I might display two frames, placing the contents of the document ch17_08.html in one and ch17_09.html in the other:

Listing ch17_07.html
 <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">     <head>         <title>             Using XHTML Frames         </title>     </head>     <frameset cols = "50%, 50%">  <frame src="ch17_08.html" />   <frame src="ch17_09.html" />  </frameset> </html> 

Here's ch17_08.html:

Listing ch17_08.html
 <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">     <head>         <title>             Using XHTML Frames         </title>     </head>     <body bgcolor=red>     <h1>         <center>         This is frame 1.         </center>     </h1>     </body> </html> 

And here's ch17_09.html:

Listing ch17_09.html
 <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">     <head>         <title>             Using XHTML Frames         </title>     </head>     <body bgcolor=cyan>     <h1>         <center>         This is frame 2. </center>     </h1>     </body> </html> 

The result of this XHTML appears in Figure 17-5.

Figure 17-5. Displaying XHTML frames.

graphics/17fig05.gif

That's all it takes to create and display frames in XHTML, but bear in mind that the W3C has apparently targeted frames for extinction . Will stylesheets be able to take over what frames do today? What about XFrames? That remains to be seen. I'll take a look at handling stylesheets now.



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

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