2011-12-05 5 views

Répondre

1

mais non testés, essayez ceci:

Pour

# 1:

$('a').each(function() { 

    var that = $(this); 
    var href = that.attr('href'); 

    if(href.search('yourdomain.com') != -1) {  
     that.attr('href', href+'?id=t'); 
    } 

}); 

Pour # 2:

$('a').filter(function() { 
    return this.hostname && this.hostname !== location.hostname; 
}).each(function() { 
    var rel = $(this).attr('rel'); 
    if(rel) { 
     $(this).attr('rel', rel + ' external'); 
    } else { 
     $(this).attr('rel', 'external'); 
    } 
}); 

$('a[rel*=external]').click(function() { 
    window.open(this.href); 
    return false; 
}); 
+0

Merci. Je vais essayer et rendre compte. – TDave00

+0

Fonctionne parfaitement. Merci. J'adore ce site. – TDave00

0

d'abord attribuer une classe "entrant" à tous les liens entrants et "sortants" à tous les liens sortants $ (document) .ready (function() {

$('a.inbound').each(function(){ 
var h = $(this).attr('href'); 
$(this).attr('href',h+'?id=t'); 
}); 

$('a.outbound').attr('target','_blank'); 


}); 
+0

Désolé, il n'était pas réaliste d'ajouter une classe et de différencier tous les liens entrants et sortants sur mon site. Merci. – TDave00

Questions connexes