Open link in a new window in XHTML 1.0 Strict June 24, 2009

As you may notice using target=”_blank” breaks XHTML 1.0 Stric validation. And here you are a solution with jQuery:

  1. Add rel=”external” for links that you want to be opened in a new window
  2. Include the following jQuery script:

    $(function() {
    $("a[rel*='external']").click(function() {$(this).attr('href'), 'external', '');
    return false;

But I agree that it’s annoying when link is opening in new tab(window) without your acceptance. Even for external links users can use hot key combination (Command + T in mac os or Ctrl + T in windows) to open a link in new tab. We should give user a choice to decide personally whether he/she wants to open a link in the same window or external. Or at least to notify somehow. Using popup window or even icon near the link that tells user that this link is external.

One Comments February 12th, 2013

It seems like you really understand plenty related to this subject matter and this
demonstrates through this article, named “Alex

Leave a Reply