Default Link Behavior In Frames
When you have a page with links loaded into a frame, the links will load in the same frame the link is in by default. So, say, you have a page in a left column with a link to another page. By default the linked page would load in the same left column that the link was in.
This can be useful, but often we want to use frames to make a row or column of links that will load in a different frame. To do this we must follow two simple steps: 1) Naming our frames. And, 2) Targeting our links. Here's an example.
Naming Frames
Naming frames couldn't be any easier. You just make up a name and use the NAME attribute in the individual <frame> tags.
<html>
<head>
<title>My First Frames</title>
<frameset cols="200,*">
<frame src="test5.htm" name="links">
<frame src="test1.htm" name="main">
</frameset>
I named my frames "links" and "main". It helps to make your names descriptive. The "test5.htm" is the black page with the white links on it from the example.
Targeting Links
The links on my links page ("test5.htm") use a TARGET attribute set to "main". This will cause the link to be loaded in the frame named "main" instead of the default "links" frame.
<a href="test2.htm" target="main">
Link 2</a>
This link would load the page "test2.htm" into the frame named "main". Really simple. The big drawback is that you can only load one page into one frame with each link. To do more, like load three or more frames, requires Beginning JavaScript.
This works in reverse, too. You can make a link on a page in the "main" frame and have it load in the "links" frame. The link in the "main" frame would look like this:
<a href="links2.htm" target="links">
New Links</a>
This would load a "links2.htm" page into the frame named "links" from the frame named "main". An example of this linking is in the example. If you click the "Link 3" link, the blue page that loads has a link that will load a different links menu.
Summary & Exercises
There's just a couple of things to remember:
Name your frames by using the FRAME attribute in the <frame> tags.
Use the frame's name in a TARGET attribute in a link's <a> tag. This link can be in any frame and will always load the linked page into the named frame.
Make this example in full using your own sample pages. Make a frameset with three rows and get different link lists to load in different rows. Remember that you can only load one frame at a time without using JavaScript.
To Next Advanced HTML Lesson
Back To Advanced HTML Index
|