Adding the nofollow attribute to external links with jQuery
Filed under: jQuery
comments (13) Views: 10,905
Today over at House of Fusion Jeff Becker asked:
I'm looking for a working rel="nofollow" regex to modify links. For example:
Goto <a href="http://google.com">Google</a> now!
turning it into:
Goto <a href="http://google.com" rel="nofollow">Google</a> now!
<a href="/somepage.html">This is an internal link</a>
<br /><br />
<a href="http://google.com">And this is an external link, with no follow</a>
Secondly the 45 characters of jQuery needed to convert all external facing URLs and add the nofollow parameter
All hail jQuery.
If this article was interesting, or helpful, or even wrong, please consider leaving a comment, or buying something from my wishlist. It's appreciated!