Return to Snippet

Revision: 52398
at October 21, 2011 20:48 by odenijs


Initial Code
var linkRewriter = function(old_domain, new_domain) {
    $('a[href*="' + old_domain + '"]').each(function() {
        if ($(this).attr('href') == old_domain ) {
			$(this).attr('href', $(this).attr('href').replace(old_domain, new_domain));
		}
    });
};

linkRewriter('www.olddomain.com', 'www.newdomain.com');

Initial URL


Initial Description


Initial Title
Replace domain on all href attributes

Initial Tags
javascript, replace, jquery

Initial Language
JavaScript