I lost all my content when the blog got hacked and my hosting company could not restore it. I have subsequently unearthed a heap of old posts (that had synced to Facebook as Notes). It’s really interesting (and quite funny) to see what I was busy with so many years ago!

1. Standard’s complaint code

As more and more sites strive for standards-compliant code that passes validation, the developer now faces a conundrum: the once simple process of adding the target attribute for links opening in a new browser window or tab will not validate.

You do NOT want a visitor to click away from your site. It took all kinds of wizardry (or hard cash!) to get the user to your site, and now you want to keep him/her there.

2. target

The traditional method was to use the target attribute of the tag, for example:

<a href="www.anotherdomain.com/page.htm" target="_blank">Click me</a>

This, however, will not validate as HTML 4.01 Strict or XHTML 1.0 Strict, as the target attribute is deprecated in both. If like me, you have opted to start coding standards-compliant code, this presents a new challenge: how do I stop my visitors from “clicking away” from my site?

3. Differentiate

Let’s differentiate between links here:

  1. Links that form part of your site’s navigation
  2. Links to resources within your site (images, PDF’s, etc)
  3. Links that lead to external pages or resources

In the case of links in the first class, as you are surely not using frames (!!), there is no real need for these pages to open in a new window or tab — in fact, quite the opposite. As such, they should visually form part of a navigation structure (navigation bar, breadcrumb navigation), thereby implicitly indicating that the link is to another part of the same site. I think users are used to this idea.

4. JavaScript

You do of course have the option of using unobtrusive JavaScript to open the link in a new page.

I have heard of users setting their browser to open ALL links in a new tab when clicked!

5. Educate

The solution I believe boils down once again to educating the user to either right-click on links that do not form part of the site’s navigation, and select Open in New Tab, or centre-clicking or clicking with the scroll-button on the mouse (if they have one).

By MisterFoxOnline

Mister Fox AKA @MisterFoxOnline is an ICT, IT and CAT Teacher who has just finished training as a Young Engineers instructor. He has a passion for technology and loves to find solutions to problems using the skills he has learned in the course of his IT career.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.