Hopefully someone can explain some odd behavior I\'ve encountered with jQuery. The following script is looking for relative links on my page and replacing them with absolut
This is not pretty, but it should work across browsers:
$(document).ready(function() {
$("a[href^='/']").each(function(){
var cur_href = $(this).attr("href");
if( cur_href.indexOf( "http" ) !== -1 ) {
$(this).attr("href", cur_href);
} else {
$(this).attr("href", 'http://www.mysite.com'+cur_href);
}
});
});