Tik pagal išorines nuorodas - CSS-gudrybės

Anonim

1 technika

$('a').filter(function() ( return this.hostname && this.hostname !== location.hostname; )).addClass("external");

2 technika

$.expr(':').external = function(obj) ( return !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname); ); $('a:external').addClass('external');

3 technika

$('a:not((href^="http://your-website.com")):not((href^="#")):not((href^="/"))').addClass('external');

4 technika

$('a').each(function() ( var a = new RegExp('/' + window.location.host + '/'); if (!a.test(this.href)) ( // This is an external link ) ));