Open Link in New Window

This page explains and demonstrates how to create a link that opens in a new browser window. The quickest way to open a link in a new window is to add target="_blank" to your <a> tag (which of course, is the HTML tag to create a link).

Here's an Example:

Source CodeResult

Create a website (Link opens in new window)

Named Windows

You can take this a step further and create a name for the new window. This can be useful in case you want to open more than one link in the same window (instead of opening a new window for each link). In other words, when a user clicks on the first link, it will open a new window. Then, each time the user clicks on a different link, the new link will load into that same window.

Probably easier to show you an example.

Try clicking on the first link below, then go back and click on the second link. You'll see that, when you click on the second link, it loads into the same window that the first link loaded into.

Source CodeResult

Web hosting (Link opens in new window)

Database (Link opens in the same window that the previous link loaded into)

As you can see, I created a name for the new window called "external". I only called it this to give it some sort of meaning (i.e. "external" for external links). I could have called it anything - say "Bob", "Mary", or even "Harold".

You don't have to stop at one named window, you could create two or more. Having said this, try to remember your users. As a website visitor, it can be annoying if too many different windows are opening up.

Frames

Named windows are perfect for loading a link into a frame. For example, if you have an iframe, you could open the contents of a link into the iframe and the link doesn't need to be within the iframe itself.

Example:

Source CodeResult

Search for a domain name (Link opens in iframe)

About HTML.am

HTML.am was created in order to provide HTML tools, codes, tutorials, and other resources to help webmasters create and maintain their HTML documents.

HTML.am aims primarily at beginners, but may also be useful to web professionals.

About the HTML Codes

The HTML codes on this website are provided free of charge, for you to use however you wish. Feel free to modify the code to suit your own needs.

My Related Sites

Here are some of my other sites: