Sunday, September 20, 2009

Targeting

<A href="URL" target="_blank">

For those who are unaware, a more "proper" way of writing HTML is to exclude the target parameter from the <A> anchor tag. This has been commonly used on many sites to open links in new windows. From the different documentation that I've read on the internet, using HTML to open new windows is deprecated because it causes problems with braille readers and other devices meant to assist the impaired.

Accessibility aside, my own thoughts on this matter are that web users should be given the choice as to when they feel it's necessary to open a link in a new window or not; HTML shouldn't dictate this. However, when approaching this in a business perspective, there are also many legitimate reasons that justifies why links should open in a new window. One way to overcome the accessibility requirements is to:

  1. Build the site where <A> anchors do not contain the target parameter
  2. Instead, add a class to those anchors <A CLASS="external-link"/>
  3. When the page loads, use javascript to:
    • crawl through the page
    • check all <A> anchors with the "external-link" class
    • inject the "target" parameter into the tag

There are different ways to approach this issue and depending on the business goals, this isn't the always best. The downside to this method, although minor, is that by crawling through the page, you are increasing the rendering time when the page loads. This is, of course, only an issue if the browser is on a slow device, the page contains a lot of objects or if the user is running on IE6.

No comments:

Post a Comment