Answer for How do I make all links nofollow and open in a new window?

Yes there is a very easy way to do this. You can use the following code in WordPress, Blogger or any other CMS.

<script type='text/javascript'>
var a = $(this);
var href = a.attr('href');
$(document).ready(function() {

$("a[href^='http://']").each(function () {
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
$(this).attr('title', 'Click to open in a new window');
$(this).attr('rel', 'nofollow');
}
}
);
$("a[href^='https://']").each(function () {
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
$(this).attr('title', 'Click to open in a new window');
$(this).attr('rel', 'nofollow');
}
}
);

});

</script>

Answer for How do I make all links nofollow and open in a new window? was last modified: June 25th, 2015 by Maximus Mccullough