Created
December 11, 2014 17:35
-
-
Save yenleidong/be678080078d24bebce2 to your computer and use it in GitHub Desktop.
Blogger, Put ALL External To Target_Blank
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
<!-- ALL External To _Blank, Put on above </head> --> | |
<script type='text/javascript'> | |
$(document).ready(function() { | |
$("a[href^='http://']").each( | |
function(){ | |
if(this.href.indexOf(location.hostname) == -1) { | |
$(this).attr('target', '_blank'); | |
} | |
} | |
); | |
$("a[href^='https://']").each( | |
function(){ | |
if(this.href.indexOf(location.hostname) == -1) { | |
$(this).attr('target', '_blank'); | |
} | |
} | |
); | |
}); | |
</script> | |
<!-- End Of ALL External To _Blank --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment