-
-
Save maxlipsky/bc95db6217a8d2285eee39d2359ff9e6 to your computer and use it in GitHub Desktop.
Jquery snippet to add target="_blank" to all external links in a documen and force PDFs to open in a new window/tab as well.Replace mydomainname with yours to skip internal links.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment