Named Frame or Window Targets

As we discussed in Section 11.4.1, you can label a frame by adding the name attribute to its <frame> tag.[74] Once named, the frame may become the destination display window for a hypertext-linked document selected within a document displayed in some other frame. You accomplish this redirection by adding the special target attribute to the anchor that references the document.

The target Attribute for the <a> Tag

If you include a target attribute within an <a> tag, the browser loads and displays the document named in the tag’s href attribute in a frame or window whose name matches the target. If the named frame or window doesn’t exist, the browser opens a new window, gives it the specified label, and loads the new document into that window. Once this process has been completed, hypertext-linked documents can target the new window.

Targeted hypertext links make it easy to create effectivce navigational tools. A simple table of contents document, for example, might redirect documents into a separate window:

<h3>Table of Contents</h3>
<ul>
  <li><a href="pref.html" target="view_window">Preface</a>
  <li><a href="chap1.html" target="view_window">Chapter 1</a>
  <li><a href="chap2.html" target="view_window">Chapter 2</a>
  <li><a href="chap3.html" target="view_window">Chapter 3</a>
</ul>

The first time the user selects one of the table of contents hypertext links, the browser opens a new window, labels it “view_window,” and displays the desired document’s contents ...

Get HTML & XHTML: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.