Skip to content

Instantly share code, notes, and snippets.

@yenleidong
Created December 11, 2014 17:35
Show Gist options
  • Save yenleidong/be678080078d24bebce2 to your computer and use it in GitHub Desktop.
Save yenleidong/be678080078d24bebce2 to your computer and use it in GitHub Desktop.
Blogger, Put ALL External To Target_Blank
<!-- 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