PageResource.com - Web Development Tutorials

Opening a New Browser Window

How make a link open in a new browser window
To get a link to open in a new browser window, what you do is add the target="_blank" attribute to your link tag, like this:

<a href="http://www.pageresource.com/linkus.htm" target="_blank">
Link to us!</a>

This will give you the following link:

Link to us!

Go ahead and click on it. Your browser will open a new window with my reciprocal links page in it (some newer browsers may open a new tab in the same window). You will need to close the window when you are finished. Use the "close" option rather than the "exit" option, because the "exit" option could make you exit your browser entirely!

You can try it with an image as well:

<a href="http://www.pageresource.com/linkus.htm" target="_blank">
<img src="http://www.pageresource.com/images/scare.jpg" />
</a>

Now you have the clickable image:

sample image linking to a page in a new window

There is also a way to do this using JavaScript, which gives you more options on the appearance of the new window. If you are interested, go to the section Opening a New Window with JavaScript.

Well, that does it for this section. So, let's go on to the next section, Fixed Backgrounds.


Copyright © The Web Design Resource. All rights reserved. | Contact Us | Privacy Policy