Forked from wpscholar/jquery.external-links-new-window.js
Created
December 23, 2019 21:11
-
-
Save jstnbr/f52a8ac044a14ab4299c1775d7bc4115 to your computer and use it in GitHub Desktop.
Open all external links in a new window
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
/** | |
* Open all external links in a new window | |
*/ | |
jQuery(document).ready(function($) { | |
$('a') | |
.filter('[href^="http"], [href^="//"]') | |
.not('[href*="' + window.location.host + '"]') | |
.attr('rel', 'noopener noreferrer') | |
.attr('target', '_blank'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment