Frames
Part 2
Adam's HTML Planet - Home Page
list of tutorials next tutorial [Forms]

This is the second part of the frames tutorial

In this part of the tutorial we'll create the files to go in the frameset we made in Part 1.

We'll need three files - a menu with a couple of links in the top of the screen, a main page to display in the rest of the screen and a file to link to so that we can experience defining targets.

  1. Copy the text for the 3 files below into your text editor
  2. Save the files using the names suggested - it won't work properly if you don't
  3. Open the file frameset1.htm and either cheer or go back and check what went wrong :)

framemenu.htmframepage1.htmframepage2.htm
<HTML>
<HEAD>
<TITLE>Frames Menu</TITLE>
</HEAD>
<BODY>
<div align="center"> Text link to <A HREF="framepage1.htm" TARGET="PAGE">Page 1</A> -
Text link to <A HREF="framepage2.htm" TARGET="PAGE">Page 2</A></div>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Frames Page One</TITLE>
</HEAD>
<BODY>
<H1>Page One</H1>
This is Page One in our frameset exercise.
This page should change when the links are clicked in the menu at the top of the page but the menu should remain constant.
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Frames Page Two</TITLE>
</HEAD>
<BODY>
<H1>Page Two</H1>
This is Page Two in our frameset exercise and, hopefully, it should all work brilliantly.
This frame changes when the links are clicked in the menu at the top of the page but the menu remains constant.
</BODY>
</HTML>

Let's look at this in a bit more detail.

framemenu.htm
This file gives us a centred couple of text links to the two other files we've made. The critical thing to notice here is that the links tags to the files files have the addition of a 'target'. In the frameset file we named the main bit of the page [the largest section of the page] "page" and this is the 'target' i.e. where we're aiming the file at. This is the bit that can go wrong!
If you're linking from your webpages to a page on someone else's site it is essential to use <target="_top"> or their website will display in your frames and it can all get very confusing - especially if their site also uses frames. The '_top' target attribute opens the link in the whole of the window and saves a whole heap of grief!

My advice would be to leave frames alone unless they are absolutely necessary - and to ask yourself that very question before you take the plunge! :)

To find out more about the FRAMESET and FRAME tag attributes check out my TAG LIST Page


Go to the top of the pageUp Arrow to decide where to go next