Share this Page URL

Chapter 13. Fooling Around with Frames > Teaching Frames and Links to Get Along - Pg. 149

Fooling Around with Frames 149 So how do you fill in the frames? You have to specify a separate content page to show in each frame. You do that by adding the SRC attribute into each of the <FRAME> tags. Here's the general format: <FRAME SRC="URL"> As you might expect, the URL part is the address of the web page you want to display in the frame. Here's an example (frame3.htm on this book's CD): <HTML> <HEAD> <TITLE>Horizontal Frames with Content</TITLE> </HEAD> <FRAMESET ROWS="25%,75%"> <FRAME SRC="1.htm"> <FRAME SRC="2.htm"> </FRAMESET> </HTML> Here, 1.htm and 2.htm are just regular HTML web pages. Figure 13.6 shows how things look in the browser. Notice that 1.htm gets displayed in the top frame and 2.htm gets displayed in the bottom frame. Figure 13.6. To get the frame page to show something useful, specify a separate content page for each frame. Teaching Frames and Links to Get Along What happens if one of your framed content pages contains a link? Well, clicking the link loads the page as usual, but you can't be sure where the page appears. In some browsers, the new page takes over the entire window and your carefully laid out frames are toast. In other browsers, the new page appears in a separate window. To avoid this random behavior, you need to control exactly where the linked pages show up. The trick is that you first have to assign a name to each frame. After that's done, it becomes an easy matter of modifying your link tags to specify the name of the frame in which you want the page to load. To assign a name to a frame, you drop the NAME attribute inside the <FRAME> tag, like so: <FRAME SRC="something.htm" NAME="Whatever">