tutorial home previous panel: Introduction next panel: Targeting Windows

Targeting Windows: Activating New Windows

Programming a hyperlink to activate a new window is extremely simple. All you have to do is add the code target=_blank to the hyperlink. For example, if your original code is

<a href=nextdoc.html>
  next document

then all you need to do is change it to

<a href=nextdoc.html target=_blank>
  next document

Then, if your visitor activates the hyperlink with a frames-capable browser, a new browser window will be created and nextdoc.html will appear in the new window, leaving the old window untouched. In fact, because the old window remains on the screen, the pain-loving user can activate the window-generating hyperlink as many times as he pleases, and a new window will appear each time.

Many web sites use this feature to send their readers to other sites without actually losing them. The user surfs the new web site until he is satisfied, and then as soon as he closes his browser window, he discovers that the old window is still there and presumably continues surfing where he left off.

In general, programming links to fire in new windows is not very nice. Here's why: Most browsers already offer the ability to open a link in a new window (right click on any link and watch), but at the user's option. And that's the way it should be: reader's choice. Whenever you insert target=_blank into a hyperlink, you take away that choice. (And it can also be construed as a sign that you are desperate to retain the reader's attention.)

Next: Targeting Windows: Targeting Windows

[ menu | previous page | next page ]