attr('href')-Bug

attr('href')-Bug


Just found an amazing bug of jQuery (used Version 1.2.2):
I just tried to replace the href of links of a site by prepending a
tracking-URL:
$(function()
{ $('a').each(function()
{
$(this).attr('href', 'http://www.tracking.com/?url=/'+escape($
(this).attr('href')) );
});
});
This function replaces the linktext in IE, if it's equal to an URL
This works:
<a href="http://www.google.com/">Google</a> ===> <a href="http://
www.tracking.com?url=http%3A//www.google.com/">Google</a>
This doesn't work:
<a href="http://www.google.com/">http://www.google.com</a> ===> <a
href="http://www.tracking.com?url=http%3A//www.google.com/">http://
www.tracking.com?url=http%3A//www.google.com/</a>
I found a work around by first replacing the link text, changing the
href and replacing the link text again, but.... ;-)