/* 定义替换对象键值 */
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;
}
栗子:
“http://XXXX:8088/test?uesrID=#userID#” 替换成对应数值 “http://XXXX:8088/test?uesrID=12345”;
“http://XXXX:8088/test/#userID#” 替换成对应数值 “http://XXXX:8088/12345”;