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 Code | Result |
---|---|
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 Code | Result |
---|---|
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 Code | Result |
---|---|
Search for a domain name (Link opens in iframe) |