Forked from wpscholar/jquery.external-links-new-window.js
Last active
August 22, 2016 14:57
-
-
Save skillmatic-co/2628499769383b3bbbeb24a739544d08 to your computer and use it in GitHub Desktop.
Open all external links in a new window
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
$('article.post .entry-content a').not('[href*="mailto:"]').each(function () { | |
var isInternalLink = new RegExp('/' + window.location.host + '/'); | |
if ( ! isInternalLink.test(this.href) ) { | |
$(this).attr('target', '_blank'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment