//获取替换url参数后的url数据 function GetReplaceUrl(paramName, replaceWith) { var oUrl = this.location.href.toString(); var re = eval(‘/(‘ + paramName + ‘=)([^&]*)/gi‘); var nUrl = oUrl.replace(re, paramName + ‘=‘ + replaceWith); return nUrl; }; //替换url不刷新 function ReplaceUrl(paramName, replaceWith) { window.history.replaceState(null, null, GetReplaceUrl(paramName, replaceWith)); };
ReplaceUrl("id", 3);
将url中id替换为3
原文:https://www.cnblogs.com/zhaogaojian/p/11063785.html