Hi Kris,

jQuery should be normalizing the href attribute when you use .attr('href'). Not sure why it's not working for you.

In any case, you should be able to do this a bit more easily:

var path_prefix = '/cms/';
$('#content_main a:not(.external)').attr('href', function() {
      return path_prefix +    this.pathname.replace(/^\//,'');
});

Here is a test page:

http://test.learningjquery.com/href.html

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Dec 11, 2008, at 10:20 AM, Kris wrote:


Own workaround:

if(document.domain=='localhost') { var root_url = 'http://localhost/
project/'; } else { var root_url = 'http://www.mydomain.com/inprog/
project'; }
$("#content_main a:not(.external)").attr('href', function() {
 orig_url = $(this).attr('href');
 if(orig_url.substring(0,4)=='http') { orig_url = orig_url.substr
(root_url.length,orig_url.length); } // IE Fix
 return path_prefix + orig_url;
});

Reply via email to