Created
January 25, 2018 16:27
-
-
Save therealkevinard/f90d0be4ddf50fceaee1a342869c369a to your computer and use it in GitHub Desktop.
Open all external links in new tab
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
jQuery('a').map(function (i, el) { | |
var elem = $(el); | |
var href = elem.attr('href'); | |
var host = window.location.host; | |
if (href.indexOf(host) < 0 && href.indexOf('http') > -1) { | |
elem.attr('target', '_blank'); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment