wayne on September 15, 2008
One method I use to help keep visitors on my site is by creating my hyperlinks so they open a new window when they are clicked. Patty over at Low-Carb Patty asked how she might create a hyperlink that when clicked, would open a new window, instead of taking the user away from her site. This is easily done by adding a property to the anchor (a) tag.
If you are not familiar with the basic structure of a hyperlink, you might want to read my article on how to create a hyperlink before continuing. This link will also open in a new window, just to show what I'm talking about. Isn't that clever?
No, not really.
Why Define Hyperlinks to Open a New Window?
"Why would one want to have their links open in a new window?", you might ask. The primary reason a blogger would do this is to keep the user on their site. Just because you provide a link, it doesn't mean you want the visitor to leave your site, does it? Maybe, maybe not. It really depends on what you are trying to achieve. For instance, when I create hyperlinks in my posts, I consider why I'm providing a link. Is it supplementary to the content? Is it simply a reference to deeper information than I intend on providing? In both of those cases, I might consider having the hyperlink open a new window, so you, the visitor, can get whatever information your linking to, yet still resume where you left off in my post.
The way I see it, if I'm linking to my own content, I won't open a new window. However, if I am referring to another blog or web site, I'll have a new window open to display the web page. It keeps the user on my blog, because honestly, I don't want anyone to leave. I think you probably feel the same way.
Create a Hyperlink That Opens a New Window
The basic structure of a hyperlink looks like this:
<a href="http://www.waynejohn.com">Visit Wayne, He's a Hoot!</a>
As you can see, we have all we really need to create a link and make it go somewhere. But how would we make it open a new window? Easy. We need to add one more property to the 'A' tag to make it do what we want. All we need to add is:
target="_blank"
That's it! Just like the href property/value pair (href="some value"), we simply include the target="_blank" to the 'A' tag and we're done. Here is what the finished product will look like:
<a href="http://www.waynejohn.com" target="_blank">Goofball Wayne</a>
Sometimes, editors (not people, the ones we use to write posts with) will provide this functionality as an option for you when you create a hyperlink. Blogger does not do this, you need to view the HTML source, find the 'A' tag you want to modify and then add the target="_blank" value pair to the hyperlink definition.
Conclusion
I know there are many people out there that find it a bit frustrating when they create a link, only to lose visitors to the link destination, never to see them again. This is one small step you can take to help create a user experience on your site that you intend.