Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

562 LESSON 20: Working with Frames and Linked Windows


The previous two examples opened each of the web pages in a new browser window. The
third link, however, uses the target="yellow_page" statement to open the green page
in the window named yellow_page. You accomplish this using the following code in
parent.html:
<p><a href="green.html" target="yellow_page">Replace</a> the yellow page
with the Green Page.</p>

Because you already opened the yellow_page window when you clicked the link for
the yellow page, the green page should replace the page that’s already in it. To verify
this, click the third hyperlink on the red page. This replaces the contents of the yellow
page (with the yellow_page target name) with the green page (green.html), as shown in
Figure 20.5.

The Tag


When you’re using the target attribute with links, you’ll sometimes find that all or most
of the hyperlinks on a web page should point to the same browsing context. For example,
you might want all the links on a page to open in a new window, so customers don’t for-
get about your home page.
In such cases, instead of including a target attribute for each <a> tag, you can use
another tag, <base>, to define a global target for all the links on a web page. The <base>
tag is used as follows:
<base target="window_name">
If you include the <base> tag in the <head>...</head> block of a document, every
<a>tag that doesn’t have a target attribute will use the value of the base tag’s target
attribute as its default target. For example, if you had included the tag

FIGURE 20.5
green.html dis-
played in the web
browser window
named green_
page.


Free download pdf