Add target=”_blank” to all external links and Force PDFs to open in a new window with jQuery

Replace mydomainname with yours to skip internal links.

<script type="text/javascript">/*<![CDATA[*/
 
  $(document).ready(function(){
	
   // external links to new window
    $('a[href^="http://"]').not('a[href*=mydomainname]').attr('target','_blank');
    
    // force PDF Files to open in new window
    $('a[href$=".pdf"]').attr('target', '_blank');
 
  });
 
 /*]]>*/</script>

Source