Sams Teach Yourself HTML 4 in 24 Hours

Sams Teach Yourself HTML 4 in 24 Hours

By Dick Oliver

Linking Between Frames and Windows

The real fun begins when you give a frame a name with the name attribute in the <frame /> tag. You can then make any link on the page change the contents of that frame by using the target attribute in an <a> tag. For example, Figure 21.3 includes the following tag:

<frame src="greeting.htm" name="main">

This displays the greeting.htm page in that frame when the page loads and names the frame "main".

In the top frame, listed in Figure 21.4, you will see the following link:

<a href="facts.htm" target="main"><img src="facts.gif" border=0 /></a>

When the user clicks this link, facts.htm is displayed in the frame named main (the lower frame). To accomplish this sort of interactivity before the invention of frames, you would have had to use complex programming or scripting languages. Now you can do it with a simple link!

If the target="main" attribute hadn't been included, the facts.htm page would have been displayed in the current (top) frame instead.

To save space, I haven't listed the facts.htm page in a figure; it's just a regular Web page with no special frame-related features. You can see what the top of it looks like in Figure 21.2, and you can see this whole frameset online at http://24hourHTMLcafe.com/hour21.

Share ThisShare This

Informit Network