Open all external links in new window
$('a[href*="http"]').each(function() { var a = new RegExp('/' + window.location.host + '/'); if(!a.test(this.href)) { $(this).attr('target','_blank'); } });