Targeting Windows

The problem with the hypertext medium is that when a user clicks on an interesting link on your page, he might never come back! One currently popular solution to this problem is to make the target document display in a second browser window. In that way, your page is still readily available.

Use the target attribute of the anchor tag to launch a new browser window for the linked document. Setting the target="_blank" attribute causes the browser to open a fresh browser window. For example:

<A HREF="http://www.webreview.com/" TARGET="_blank">...</A>

If you set every link on your page to target a _blank window, every link will launch a new window, potentially leaving your user with a mess of open windows.

A better method, especially if you have more than one link, is to give the targeted window a specific name, which can then be reused by subsequent links. The following link will open a new window called “display”:

<A HREF="http://www.webreview.com/" TARGET="display">...</A>

If you target every link on that page to the “display” window, each targeted document will open in the same second window.

The target attribute is most often used in conjunction with framed documents. The syntax and strategy for using the target attribute with framed documents is discussed in Chapter 11.

Warning

Some browsers do not support the target attribute (including WebTV and MSIE2.0 and earlier). Furthermore, Netscape Navigator 4.0 has a bug that prevents the new named window from coming to ...

Get Web Design in a Nutshell 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.