Created
July 13, 2016 09:49
-
-
Save ryanlid/6b169da96b68a15ec141d97f54cf055c to your computer and use it in GitHub Desktop.
jQuery 在新窗口打开外部链接
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> | |
var myURL = location.protocol + '//' + location.hostname; | |
$('a[href^= "http://"]').not('[href^= "'+myURL+'"]').attr('target','_blank'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment