jQuery对url的操作

// 修改URL中指定参数的值
function changeURLArg(url,arg,arg_val){
var pattern=arg+'=([^&]*)';
var replaceText=arg+'='+arg_val;
if(url.match(pattern)){
var tmp='/('+ arg+'=)([^&]*)/gi';
tmp=url.replace(eval(tmp),replaceText);
return tmp;
}else{
if(url.match('[\?]')){
return url+'&'+replaceText;
}else{
return url+'?'+replaceText;
}
}
return url+'\n'+arg+'\n'+arg_val;
}
 // 删除url中某个参数
function funcUrlDel(name){
var loca = window.location;
var baseUrl = loca.origin + loca.pathname + "?";
var query = loca.search.substr();
if (query.indexOf(name)>-) {
var obj = {}
var arr = query.split("&");
for (var i = ; i < arr.length; i++) {
arr[i] = arr[i].split("=");
obj[arr[i][]] = arr[i][];
};
delete obj[name];
var url = baseUrl + JSON.stringify(obj).replace(/[\"\{\}]/g,"").replace(/\:/g,"=").replace(/\,/g,"&");
return url
};
}
上一篇:CSS学习篇核心之——盒子模型


下一篇:V-rep学习笔记:Reflexxes Motion Library 2