With the following:
$("a[href^='http:']:not([href*='"+window.location.host+"'])").each(function(){
$(this)
.attr("href","http://mysite.com?url="+$(this).attr("href"))
.addClass("external");
});
This HTML:
<a href="http://www.google.com">Google</a>
<a href="http://localhost/somepage.html">Localhost</a>
Becomes this:
<a class="external" href="http://mysite.com?url=http://www.google.com">Google</a>
<a href="http://localhost/somepage.html">Localhost</a>
Jonathan Sampson
2009-12-23 19:47:51