كود:
<script type='text/javascript'>
$(document).ready(function() {
$("a[href^='http://']").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
$(this).attr('rel', 'nofollow');
}
}
);
$("a[href^='https://']").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
}
}
);
});
</script>
الكود يجمع بين الامرين الفتح في صفحة جديدة والـ Nofollow لانني وجدت كثير من المدونين يستخدمون كودين منفصلين مما يجعل الأمر ثقيل