-
-
Save Archie22is/84b6b01af7389a042c441dfd850285bd 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 hidden or 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