js 替换 当前URL 特定参数

js 替换 当前URL 特定参数  

2012-12-24 20:45:53|  分类: JS&JQuery |举报 |字号 订阅

 
//替换指定传入参数的值,paramName为参数,replaceWith为新值
function replaceParamVal(paramName,replaceWith) {
    var oUrl = this.location.href.toString();
    var re=eval('/('+ paramName+'=)([^&]*)/gi');
    var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
    this.location = nUrl;
}
原文地址:https://www.cnblogs.com/afei-happy/p/3848414.html