Open a link in a new window in XHTML

XHTML1.1 does not support the target attribute and so my preferred method for opening links in a new window is:

$(document).ready(function() { 
  $('a[rel*=external]').click(function() { 
    window.open($(this).attr('href')); 
    return false; 
  }); 
});

(code from http://stackoverflow.com/questions/233467/whats-the-best-way-to-open-new-browser-window)

You simply include that snippet of jQuery and add the attribute rel=”external” to links that you want to have open in a new window.

About

Second Story creates enchanting, informative, and entertaining media experiences with innovative technologies that empower connections to ideas.

Tagged with: , ,
Posted in Technology