Created
September 12, 2010 04:27
-
-
Save gormus/575844 to your computer and use it in GitHub Desktop.
Open all the external and PDF links in a new window, with exceptions.
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
$(document).ready(function() { | |
// Open external links in a new window, except AddThis | |
$("a[href^='http']") | |
.not("[href^=#]") | |
.not("[href^=mailto]") | |
.not("href*=example.com") | |
.not("href*=addthis.com") | |
.addClass("link-external") | |
.attr('target', '_blank'); | |
// Open PDF links in a new window, | |
$("a[href$='.pdf']").addClass("link-pdf").attr('target', '_blank'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment