The address for this web page is:   http://fishcaro.crosswinds.net/day_40_linking_into_frames.htm
On to the next lesson!
Back to the COURSE SYLLABUS

40. LINKING INTO FRAMES

Linking becomes a bit more difficult when you're dealing with a framed document, and is the subject of the current lesson.

INDEX CARD #40:

INTRODUCTION: LINKING INTO FRAMES (40a)

When you have a link in a frame, the linked document loads (by default) into the same frame, like this:
BEFORE CLICKING:
AFTER CLICKING:
So, here's a good viewpoint for linking with framed documents: you're not "going to" another document, you're "bringing the other document to you"!

THE <TARGET> ATTRIBUTE (40b)

Sometimes you may not want the linked document to load into the same frame. By naming the desired target frame, and then using the TARGET attribute in the anchor tag, you can load into any frame that you want:
BEFORE CLICKING:
AFTER CLICKING:


OPENING A NEW BROWSER WINDOW (40c)

If a link contains a target name that does not exist in the current (framed or unframed) document, then a new window is opened to display the linked document, and that newly-opened window is given the target's name.

For example, the link below was created with this code:

<A HREF="http://google.com" TARGET="nonexistent_frame">Click here!</A>

Try it out and see what happens! (Please don't close the window that appears.)
Click here!

Now that the window is open, you can load something else into it. The next link was created with this code:

<A HREF="http://yahoo.com" TARGET="nonexistent_frame">Click here too!</A>
Try it out!
Click here too!

USING THE TARGET ATTRIBUTE IN THE <BASE> TAG (40d)

One common use of frames is to have a narrow table of contents on the left; each entry loads the specified document into the main frame on the right. Suppose that the main frame is named "main". It's a nuisance to have to type TARGET="main" in every single table of content entry. Instead, use the BASE tag with the TARGET attribute in the head of the table of contents document:
<HEAD>
<BASE TARGET="main">
</HEAD>
If you specify a different target for any particular link, it will override the target in the base tag.


"BUSTING OUT" OF A FRAMESET (40e)

Sometimes you don't want your linked document to be displayed in the current frame, or any other frame... instead, you want the linked document to fill the entire browser window, like this:
BEFORE CLICKING:
AFTER CLICKING:

THE "_top" RESERVED TARGET NAME (40f)

To accomplish the effect on card 40e, just use the attribute TARGET="_top" in the link. This causes the linked document to replace any frames currently displayed. (It loads at the "top level".) To get back to the framed document, the user would need to use the "BACK" feature in the browser.

The name "_top" is a reserved name; you're not allowed to give a frame of your own this name. In general, you should never name anything beginning with an underscore (_) character, since programming languages tend to use this convention for special purposes.

Printable version of Index Card 40a

Printable version of Index Card 40b

Printable version of Index Card 40c

Printable version of Index Card 40d

Printable version of Index Card 40e

Printable version of Index Card 40f

WORKSHEET #40:

ASSIGNMENT #40:

On to the next lesson!
Back to the COURSE SYLLABUS
© 2001 Carol J.V. Fisher    All Rights Reserved