Framesets
[Previous] [Main] [Next]

 
htmlFrameSet encapsulates the <FRAMESET></FRAMESET> tags, used for creating sets of frames and their individual dimensions. This class is designed to contain htmlFrame objects.  
 
The HTML specification prohibits the use of <BODY> and <FRAMESET> tags within the same document. Framesets define the placement and dimensions of frames. The only place a htmlFrameSet object can be used is in a unique kind of page, called a frameset definition document. Such a document lacks the usual <BODY> section, and has in it's place the output of one or more htmlFrameSet objects, which in turn can each contain one or more htmlFrame objects referencing specific URL's.  
 
htmlFrameSet objects are typically added only to htmlPage objects to create frameset definition documents, though you can use them in any object you wish. The htmlPage class is smart with respect to framesets. If any htmlFrameSet objects are added directly to it, htmlPage will omit the internal htmlBody object when outputting it's contents via the htmlPage::Print() method or << streaming output operator.  
 
A frameset can specify that the frames it contains are laid out in rows or columns. You can nest htmlFrameSet objects to obtain rows and columns. For example, to obtain a 2x2 frameset, you would define three framesets, A, B, and C. Framesets A and B would each have two rows. Frameset C would have two columns, the first one containing frameset A and the second column containing frameset B.  
 
 htmlPage  page ;  
 htmlFrameSet A, B, C ;  
 
 A.Rows( "*,*" ) ;  // two columns  
 A << htmlFrame( "a1""http://www.dcmicro.com" )  
   << htmlFrame( "a2""http://www.dcmicro.com/crusher" ) ;  
 
 B.Rows( "*,*" ) ;  // two columns  
 B << htmlFrame( "b1""http://www.dcmicro.com/htmlpp" )  
   << htmlFrame( "b2""http://www.dcmicro.com/support" ) ;  
 
 C.Columns( "*,*" ) ;  //  two rows  
 C << A << B ;  //  result is two rows of two columns each  
 page << C ;  
 
Either the rows or the columns attribute of a frameset must be defined. If the browser displays a blank window, it's likely that the dimensions of the rows or columns weren't properly specified. The rows and columns attributes must be specified as a comma-delimited string listing the values for the row or column sizes. Each item in the list can be one of the following:  
  • height/width of a frame in pixels
  • height/width of the frame as a percentage of the parent
  • an asterisk (*) meaning whatever remaining space is available, dividing it equally among all rows/columns that have an asterisk.
 
Several identical attributes are available for framesets and frames, such as border thickness and color. Such attributes for a frameset act as defaults for all frames within it's borders, with attributes for individual frames taking precedence for their own regions of display.  
 
When defining hyperlinks, you can control in which frame the document will load by specifying the frame name as the target of the hyperlink using the target argument of the htmlHyperLink constructor or the htmlHyperLink::Target() method. Using JavaScript, you can create a hyperlink that loads multiple frames at once (see Changing Multiple Frames in One Step for more details).  
 
To make your pages viewable by the most number of browsers, use the NoFrames() method to add content to be displayed by browsers that don't support frames.  
 
Example
 
#include <stdio.h>  
#include <stdlib.h>  
#include <dcmicro/htmlpp/htmlpp.h>  
 
int main( void )  
{  
   htmlCgi   server ;  
   htmlPage  page( "html++ example application" ) ;  
 
   //  Create a frameset of 2 rows  
   htmlFrameSet  set( "30%, 70%""" ) ;  
 
   //  Use the NoFrames() method to add content for browsers  
   //  that cannot display frames. This example has only  
   //  text, but you may want to add a htmlHyperLink object  
   //  to a non-frame version of the document.  
   set.NoFrames() << "This is displayed only by browsers "  
                    "that do not support frames." ;  
 
   //  Load connectup.com in the top row, and dcmicro.com  
   //  in the bottom row. The names "a1" and "a2" could be  
   //  used as 'targets' for other hyperlinks, or for  
   //  JavaScript access; they could also be empty strings.  
   set << htmlFrame( "a1""http://www.connectup.com" )  
       << htmlFrame( "a2""http://www.dcmicro.com" ) ;  
     
   page << set ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<FRAMESET ROWS="30%, 70%">  
<FRAME NAME="a1" SRC="http://www.connectup.com">  
<FRAME NAME="a2" SRC="http://www.dcmicro.com">  
<NOFRAMES>This is displayed only by browsers that do not support frames.</NOFRAMES>  
</FRAMESET>  
</HTML>  
 
frameset.gif  
 


©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.