Your Ad Here

Opening a New Window with Hyperlinks

Trying to open a new page when a user clicks your link but having no luck? There are a few ways this may be done. If you want to do this with script code you can do it one of two ways. Note that these ways will not work if the person visiting your site does not have scripting enabled.

 

<a href=”#” onclick=”window.open(…)”>Example 1</a>
<a href=”javascript:window.open(…)”>Example 2</a>

If you are looking for a more HTML geared way of doing it you can use the target=”_blank” inside your a href. This way is a deprecated HTML tag.

 

<a target=”_blank” href=”#”>Example 3</a>

Be careful when using this tag to open a new window. This could make visitors to your site not want to come back again. There is always a time and place to use this, such as opening a new window when someone clicks to download a file. However, if you are just using this tag while people navigate through your site, odds are they will not want to come back!

 

The effect of these tags can be different depending on the browser. For example, when I tested the target=”_blank” in IE 8 it opened a new window. In IE 7 and Firefox it opened a new tab.

 

If you are tracking the length of time visitors spend on your website then this could mess up your measurements. When the user opens a new window that leaves the browser window with your website up on a different page sitting idle, but still collecting data for how long that person is visiting. These are just speculations into why you may not want to use this command, there is no proof that I know of to turn these comments into facts. Who knows, maybe opening a new window for every click will be the new fad!

VN:F [1.6.4_902]
Rating: 0.0/5 (0 votes cast)
VN:F [1.6.4_902]
Rating: 0 (from 0 votes)




Leave a Reply