JS 去除URL指定参数
var removeURLParam = function(url,name){ var e = eval('/'+name+'=[^&]*&?/g'); url = url.replace(e, ''); if(url.substr(-1)=='?'||url.substr(-1)=='&'){ url = url.substr(0, url.length - 1); } return url; } //使用方法: var url = 'https://xiaoguan.net?id=1&age=18&name=xiaoguan'; console.log(removeURLParam(url,'age')); //返回:https://xiaoguan.net?id=1&name=xiaoguan