Wednesday, September 30, 2009

Testing a site for nofollow links with jQuery

I'm working on a site at the moment and a number of the links on the pages do not need to be followed by the search engine (or other) spiders and do not need to be indexed. These links I set with the nofollow value on the rel attribute in the anchor tag follows:

<a href="some-link-goes-here" rel="nofollow">link text</a>

Some of the pages have plenty of links and I'm never sure if I've marked all of them correctly but I would know if I could color the already marked ones. This is easily achieved with jQuery. I open up the page in FireFox and then open the Firebug Console panel and in there I type:

$('[rel=nofollow]').attr('style', 'color:Fuchsia')

This will cause all of the links on the page with the rel attribute set to nofollow to be colored pink. You can then easily perform a visual check to see if you've caught them all.

(It will actually cause any text inside any tag with a rel attribute set to nofollow to be colored pink but I believe that the only recognized tag that rel is used with is the anchor tag.

1 comment: