BreBru
Frames Lesson 2



Congratulations!!

You have a frame page! Hopefully you found that making a frame page was much easier than you thought it would be. All you needed to do was make a very simple and short FRAMESET HTML DOCUMENT to combine the two pages together. Now lets take a closer look at the tags now that you know how to write a frame page.

What the tags do:


NAMES and TARGETS

The "NAME" Game

Now follow along and lets redo your frame page a little! The first thing you will need to do is "NAME" your frames. This is done by adding the "NAME" attribute to your Frame Source tag, (FRAME SRC=), which is found on your FrameSet Document(see fiqure below). Below you will find the formal lesson on how it all works! Sometimes it is a little confusing at first, but actually is quite simple when you really think about it. We are simply naming each of the different frames on the page in the FrameSet Document and then referring to that Frame name on the menu link itself by using the Target attribute within the link. Why do we have to name them? We name them so when you click on a link from your frame menu, the page will open up inside the frame of your choice (one that you named in the FrameSet Document).

Step one

<HTML>
<HEAD>
<TITLE>
BreBru ...frame class
</TITLE>
</HEAD>
<FRAMESET ROWS="80,*">
<FRAME SRC="menu.html" NAME="menu">
<FRAME SRC="index.html" NAME="main">
</FRAMESET>
</HTML>


As you can see in the above example, we have made two simple changes. We NAMED the two frames! The first frame is NAMED "menu" and the second frame we NAMED "main". The menu.html link is the URL to your menu page, and the index.html link is the URL to your real life index page. The two frames listed here are the two default frames that will load up when the viewer goes to your FrameSet Document URL. At this point the Frame Names do nothing! We have to TARGET the NAMES for them to be useful. More on that coming up!

Next you will add the links on your menu.

Step Two

With this link we want it to open in its own separate page. So the target attribute will look like this ~ <A HREF="http://www.brebru.com" TARGET="_top">BreBru HTML</A>. Notice instead of using "main" in the target tag I used "_top". This will cause a new page to open leaving your frames behind. You need to use the "_top" tag on every outside link on your frame pages. This way the viewer will not get stuck in your frames if they view a different site. *Note ~ If you do not use any target tag then your link will load in the menu frame. We don't want that do we?

NOTE: The "_top" target name must be lower case letters.

<HTML>
<HEAD>
<TITLE>Menu Page</TITLE>
</HEAD>
<BODY>
<A HREF="index.html" TARGET="main">Home</A>
<A HREF="other page.html" TARGET="main">Name of Page</A>
<A HREF="http://www.geocities.com/bisonhtml" TARGET="_top">BreBru HTML</A>
</BODY>
</HTML>


Go to your framelesson.html and reload! To reload frames you need to go to each individual frame and right click. Then select reload frame! Do this for the menu frame and the main frame. Now try each of the links. You may need to move things around or change the sizes to fit in the frame space that you have designed.

Three ways to load a page!

1. When you click on a link in a frame and--just that frame changes pages.
2. When you click on a link in a frame and--another frame on the screen receives the information.
3. When you click on a link in a frame and--the frames go away and you get a new full page.


Here is how its done!

1. When you click on a link in a frame and--just that frame changes pages.

This is the default. It just happens without you doing a darn thing (no target tag). So, if that's all you want to happen, do nothing more than what you already know. Browsers are programmed to handle frame clicks just that way. However, for consistancy so you don't forget to target a frame you can add TARGET="_self" (see below). Lets look at the two other methods.

2. When you click on a link in a frame and--another frame on the screen receives the information.

OK, great...you've already named your frames and caused this to happen on your menu links by targeting the frame named "main". So you have seen how this works.

3. When you click on a link in a frame and--the frames go away and you get a new full page.

You need to TARGET the link to be it's own page. Easy enough! Just follow the format above but make the TARGET="_top" Note the underline before the word "top". You have already achieved doing this as well with the third menu link above! Remember it looks like this:

<A HREF="http://www.geocities.com/bisonhtml" TARGET="_top">

Magic TARGET names

Now we are going to look at other ways to use Targets! In the below Target examples you will learn how to open pages in different windows. The different target names below are standard HTML Target Names that we can also use. Remember that the Target just tells the browser where to open the page when the link is clicked!

These standard target names all begin with the underscore character.

TARGET="_blank"

This target will cause the link to always be loaded in a new blank window. This window is not named.

TARGET="_self"

This target causes the link to always load in the same window the link was clicked in. This is useful for overriding a globally assigned BASE target.

TARGET="_parent"

The _parent target causes the page to be loaded into the parent window, or frameset, containing the frame that contains the URL reference. If the reference is in a window or top-level frame, it is equivalent to the target _self

TARGET="_top"

This target makes the link load in the full body of the window (with no frames). This defaults to acting like "_self" if the document is already at the top. It is also useful for breaking out of a FRAME.

NOTE: All these special target names must be lower case letters.

As with most new things you learn, reading about how it all works is not going to quite cut it! You need to practice doing it to really learn. Using all the examples of the above targets, try them all out and play around with it. You will have fun and learn how it all works at the same time.


Putting it all together!

OK, Now you are past the hard part of this class (WELL DONE!). You know how to break up the screen using frames through the <FRAMESET> HTML document and how the NAMES and TARGETS work. We used the TARGET attribute in conjuction with the NAME attribute to tell the browser where to open a page when a link is clicked.

What do I do if a browser can't read Frames?

That's a problem. The browserly-challenged will get an error code if they attempt to log into a page with frames. Either that or they will receive a blank page. There are a couple of ways around it.

1. Don't do frames. (Oh, I could have guessed that one, Einstein!)
2. Write a page without any frames and offer a choice to go to a framed page or to a non-framed page. But that means you have to write two pages--bummer.
3. Use <NOFRAMES> and </NOFRAMES> commands.

Ooooooo...tell me more about the NOFRAMES command. Well, it's simple. You write a basic frame page - BUT - you put in the <NOFRAMES> tag as well as the ending </NOFRAMES> tag and copy or make a non frames version of the page. A browser that can not view frames will automatically view only the content between those two tags and skip the Frame part.

It all sounds simple but I still don't quite get it! First take a look at the sample coding below. Do you notice that we added a <NOFRAMES> & </NOFRAMES> tag? What is going on? If a browser can't read the frame code of the document (the browser can not read frames) then it skips over the frameset code and reads the code between the NOFRAMES tags instead. First lets pretend that we are not doing a frames page! You have a your regular HTML Document (like your index page). Now we are going to put it in with the FRAMESET DOCUMENT. We first need to add the tag <NOFRAMES> before the beginning <BODY> tag. Now add the </NOFRAMES> tag after the ending </BODY> tag. It will only read what is between these two tags (<NOFRAMES> & </NOFRAMES>.

IMPORTANT ! Do not include anything before the <BODY> tag or after the </BODY> tag. Only the tags themselves and whatever is between them.

Now we need to add the code for the FRAMESET DOCUMENT.. All you need to do is put the entire FRAMESET (but leave the ending </FRAMESET> out) code above the (<NOFRAMES>) tag. Now put in </FRAMESET> tag after the </NOFRAMES> tag. Remember to put a </HTML> tag as the last tag on your page and immediately after the </FRAMESET> tag. Thats it!! Your done! When a browser comes along that can not handle frames it will only read the content between the <NOFRAMES> & </NOFRAMES> tags. So it will view the page as a standard NONFRAME page. On the other hand if a browser comes along that DOES read frames (most do) then it will NOT read the content between the <NOFRAMES> & </NOFRAMES> tags and only read the code for the FRAMESET DOCUMENT!


<HTML>

<HEAD>

<TITLE>Blah blah blah

</TITLE>

</HEAD>

<FRAMESET COLS="50%,50%">

<FRAME SRC="PAGE_A.htm">
<FRAME SRC="PAGE_B.htm">

<NOFRAMES>

<BODY>

Your entire non frame version code goes here,
in between the two NOFRAMES Tags.

</BODY>

</NOFRAMES>

</FRAMESET>

</HTML>




Frames Browser sees this

Non-frames browser sees this

<html>
<head>
<title>My Frames Exam</title>
</head>
<html>
<head>
<title>My Frames Exam</title>
</head>
<frameset cols "100,*" border="0">
<frame src="menu.html">
<frame src="index.html">
<noframes>
<frameset cols "100,*" border="0">
<frame src="menu.html">
<frame src="index.html">
<noframes>
<body>
My alternative page content here
</body>
<body>
My alternative page content here
</body>
</noframes>
</frameset>
</noframes>
</frameset>
</html>
</html>


      The first column shows the code a Frames browser will read, and the second column with the code a Non-Frames browser will read.

The code in the dark grey areas is not seen by the browser in question. The Frames browser gets to the <noframes> tag then ignores everything until it gets to the </noframes> tag, then it starts reading again.

The Non-Frames browser ignores any frames related tags, because it does not know what they are.



Get What's Happening?

The person who's browser can't see frames will automatically view the non frame version that is located between the beginning and ending NOFRAMES tags. Isn't technology wonderful?


Homework

For your homework send the frame page URL you made for this lesson.