dio-v
12/4/2013 - 6:05 AM

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

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

   // 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');