How To Open Links In a New Window With jQuery
4/02/2013As you probably know, target _blank is bad. So, using jQuery instead, here are two very simple ways to open links in a new window using either "class external" or "rel external". Neither write anything into the HTML. And both work identical - its your choice. Simply place jQuery and either of these two snippets at the bottom of your page, and place the rel or class in your links, and your good to go.
jQuery class="external"
$("a.external[href^='http://']").click(function(){window.open(this.href);return false;});
The html
<a class="external"></a>
jQuery rel="external"
$('a[rel*=external]').click(function(){window.open(this.href);return false;});
The html
<a rel="external"></a>