MCCC CIS 177 - Markup Languages

5.0 Create Framesets

5.11 Nesting Frames

Nesting an internal frameset

Nesting internal framesets, or combining framesets is common to produce a single row at the top and/or bottom of the page with two columns in the center.

Click here to view example
<html>
<head><title>Page Title</title>
</head>

<frameset rows="50,*,50">
    <frame name="top" src="top2.html">

    <frameset cols="150,*">
      <frame name="left" src="menu2.html">
      <frame name="right" src="main2.html">
    </frameset>

    <frame name="bottom" src="bottom2.html">
</frameset>

<noframes>No frames content goes here</noframes>

</html>

Create an Internal Nested Frameset

  1. Edit the lab05d.html file.
  2. Create the first frameset as rows 15%, *, 15%, no columns.
  3. Make the frame with heading.html the first row.
  4. Create a nested frameset using cols 150, * for the second row adding the same border attributes as in the first frameset.
  5. Keep the frames with navbar1 and main as the two columns.
  6. Be sure to close the column frameset.
  7. Make the last row the blank.html.
  8. Save the file as lab05e.html.
  9. View the file in the browser.


Nesting an external frameset

You can also include a frameset as the source for another frameset.

Click here to view example



<html>
<head><title></title>
</head>

<frameset rows="10%,*,10%">

<frame name="parenttop" src="blank.html">

<frame name="child" src="framesetf.html">

<frame name="parentbottom" src="blank.html">

</frameset>

<noframes>No frames content goes here</noframes>

</html>

Create an External Nested Frameset

  1. Edit the lab05e.html file.
  2. Change the first frameset to two rows *, 15%, with border and frameborder equal 0.
  3. Remove the first frame.
  4. Remove the second frameset.
  5. Keep the frame named main using lab05d.html (the last demo) as the source.
  6. Remove the nested closing frameset.
  7. Keep the last row with blank.html.
  8. Save the file as lab05f.html.
  9. View the file in the browser.
5.18 Linking Frames

Review of the target attribute

Previously you learned about the target attribute that allows you to control where a link appears. By default a link will open in the same frame containing the link. The following are common built-in targets you can use. Also recall you can set your own default target using the base tag in the head section, which you can override by specifying a new target in the individual anchor tag.

  • _self - opens link in the same frame (default)
  • _blank - opens the link in a new window
  • _top - opens the link at the top, replacing frames
  • _parent - opens the link in the frame containing the current frameset. Only differenct from _top whien you nest framesets.

Linking from a menu frame to a content frame

In order to control which frame a link appears, your frames must have a name that begins with an alphanumeric character (not the underscore as in the built-in target). Designers commonly create a frameset that contains a menu frame and a main or body frame, the following example illustrates the coding of this type of targeting.

Click here to view example

In the frameset definition:

<frameset cols="150,*">

    <frame name="menu1" src="menu1.html"> <frame name="body" src="body1.html">

</frameset>

In the menu1.html page:

<a href="body1.html" target="body">Link to page 1</a>
<a href="body2.html" target="body">Link to page 2</a>
<a href="body3.html" target="body">Link to page 3</a>


Link from a Menu Frame

Click here to download lesson files

  1. Edit the navbar2.html file.
  2. Add anchor tags to link each button as follows.
    • Link button1 to main.html target main.
    • Link button2 to directions.html target main.
    • Link button3 to specifics.html target main.
    • Link button4 as a mailto link to your email address.
  3. Save your changes.
  4. View lab05g.html in the browser.


Linking from a content frame to a parent frame

When using framesets, since users can optionally open individual frames separately, it's always a good idea to include at least a link in each content page back to the home page that reestablishes the menu frame.

Click here to view example

<a href="frameseth.html" target="_top">Home</a>

Link from a Menu Frame

  1. Edit the main.html, directions.html and specifics.html files.
  2. Add anchor tags to include a link back to the home page including the menu on each of the pages.
  3. Save your changes to each page.
  4. View lab05g.html in the browser.