Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.