Welcome Login

frameset and frame tags


Note: If you want to validate a page containing frames, make sure the <!DOCTYPE> is set to either "HTML Frameset DTD" or "XHTML Frameset DTD".

Noe2: don't confuse frameset with fieldset tags.

 

frameset tag:

frameset element is a frame container for dividing a window into rectangular subspaces called frames.

In a frameset document, the outermost frameset element takes the place of body and immediately follows the head.

frame element contains one or more frameset or frame elements, along with an optional noframes element to provide alternate content for browsers that do not support frames or have frames disabled. A meaningful noframes element should always be provided and should at the very least contain links to the main frame or frames.

frameset element holds one or more frame elements. Each frame element can hold a separate document.

frameset element specifies number of columns or rows that there will be in the frameset, and percentage/pixels of space that will occupy each of them.

 

Attributes:

Attribute     Value                Description

id            id                   Specifies a unique id for an element

class         classname            Specifies a classname for an element

style         style_definition     Specifies an inline style for an element

title         text                 Specifies extra information about an element

cols          pixels               Specifies the number and size of columns in a frameset
              %
              *
                            
rows          pixels               Specifies the number and size of rows in a frameset
              %
              *
onload        script               (event attribute) Script to be run when a document load

onunload      script               (event attribute) Script to be run when a document unload

 

Eg: simple three framed page

<!DOCTYPE html>
<html>
<head></head>

<frameset cols="25%,*,25%">
  <frame src="http://www.andrewsin.com">
  <frame src="http://www.htmlhelp.com/reference/html40/frames/frameset.html">
  <frame src="frame_c.htm">
</frameset>

</html>

 

Outputs:

html-frameset1

 

rows and cols attributes:

rows and cols attributes define the dimensions of each frame in the set. rows/cols attributes takes a comma-separated list of lengths, specified in pixels, as a percentage, or as a relative length. A relative length is expressed as i* where i is an integer. Eg: a frameset defined with rows="3*,*" (* is equivalent to 1*) will have its first row allotted three times the height of the second row.

The values specified for the rows attribute give the height of each row, from top to bottom.

The cols attribute gives the width of each column from left to right.

If rows or cols are omitted, the implied value for the attribute is 100%.

If both attributes are specified, a grid is defined and filled left-to-right then top-to-bottom.

 

For further information on frameset, see here.

 

 

frame tag:

frame tag defines one particular window (frame) within a frameset container.

Each frame in a frameset can have different attributes, such as border, scrolling, the ability to resize, etc.

Attributes:

Attribute     Value                Description

id            id                   Specifies a unique id for an element

class         classname            Specifies a classname for an element

style         style_definition     Specifies an inline style for an element

title         text                 Specifies extra information about an element

frameborder   0                    Specifies whether or not to display a border around a frame
              1
              
longdesc      url                  Specifies a page that contains a long description of the content of a frame

marginheight  pixels               Specifies the top and bottom margins of a frame

marginwidth   pixels               Specifies the left and right margins of a frame

name          name                 Specifies the name of a frame

noresize      noresize             Specifies that a frame is not resizable

scrolling     yes                  Specifies whether or not to display scrollbars in a frame
              no
              auto
              
src           url                  Specifies the URL of the document to show in a frame

 

 

 

Form outputting to a different frame or window:

Frames are to be avoided wherever possible. However, if you want the output of a form to be pointed to a different frame or window, you can use the following html:

Pay special attenction to setting the target property of the html form:

<html>
<frameset cols="20%,*">
<frame src="leftindex.html" name="Left frame" >
<frame src="rightindex.html" name="Right frame">
</frameset>
</html>  


Below is the source of leftindex.html

<html>
  <body>
    <form name="Myform" method=get action="http://www.andrewsin.com/dosomething1.aspx" target="Right frame">
    <input type="submit" value="clicking in left frame but output in right frame">
    </form>
  </body>
</html>

Created on: Wednesday, November 7, 2012 by Andrew Sin