具体代码如下所示:
/* 定义替换对象键值 */ var setReferArgs = function(){ var referArgs = new Object(); referArgs['#userID\#'] = userId; referArgs['\#userName\#'] = userName; return referArgs; } /* 替换URL的参数 */ var replaceUrlParams = function(url){ var actualUrl = ""; var referArgs = setReferArgs(); for(var key in referArgs){ var e = eval('/'+ key +'/g'); actualUrl = url.replace(e,referArgs[key]); url = actualUrl; } return actualUrl; }