jquery .attr() to replace href value not workign in Safari browser : My code below is designed to append two query string parameters on all the <a href tags on my page.  The code works fine in chrome but does not work on Safari. For some reason on Safari browser it is not appending the parameters. Chrome seems to be working fine.  Any ideas why chrome and safari would have different results with these jquery functions?  From what i have read it may be related to the way i am using $this in the .each loop.  

Looking forward to your help.  



$(document).ready(function(){
	
	// function to get query string for given parameter
    function GetQueryString( field, url ) {
	    var href = url ? url : window.location.href;
	    var reg = new RegExp( '[?&]' + field + '=([^&#]*)', 'i' );
	    var string = reg.exec(href);
	    return string ? string[1] : null;
	};

	var aid = GetQueryString('affiliate'); // returns 'chicken'
	var cmp = GetQueryString('campaign'); // returns 'sandwich'
	var href_param;
	
	$('a').each(function() {
	  
		 if ($(this).is('[href*="?"')) {
	       
			href_param = '&';
			
		    }
		else
		{
			href_param = '?';
		
		}
	
		var $this=$(this);
		
		$this.attr("href",$this.attr("href") + href_param + "affiliate=" + aid + "&campaign=" + cmp);

	});
	
});