Chapter 65. Opening a New Browser Window


When a link leads to an external site, it's common for the link to open a new browser window. The external site loads in the new window, keeping the referring page alive and well in the original window.

TIP

Remember, just because you can do something doesn't mean you should do it every chance you get. Opening a new browser window works best for external links, not internal links. If a new window appears for every page on your site, your visitors will soon join the ranks of the new-browser-window-haters.


Some Web builders scoff at this strategy. They're usually the same people who hate popup windows with an intensity that Freud himself would find difficult to explain, which may or may not have something to do with the amount of clutter on the desktop. Given that external sites regularly go down, change URLs, or include techniques that disable the browser's Back button, opening a new browser window is not as sinister as it might at first appear. In fact, in some circles, it's common courtesy. Depositing your visitors on a File Not Found error message instead of the promised Web site seems less like a mistake when getting rid of the dud site is as simple as closing the new browser window.

Opening a new browser window is easy from any link. Just add the target attribute to the anchor tag, and set the value of this attribute to _blank, like this:

 <a href="http://externalsite/" target="_blank">External site</a> 



Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net