/** * 删除当前url中指定参数 * @param names 数组或字符串 * @returns {string} */ function funcUrlDel(names) { if(typeof(names)=='string'){ names = [names]; } var loca = window.location; var obj = {} var arr = loca.search.substr(1).split("&"); //获取参数转换为object for(var i = 0; i < arr.length; i++) { arr[i] = arr[i].split("="); obj[arr[i][0]] = arr[i][1]; }; //删除指定参数 for(var i = 0; i < names.length; i++) { delete obj[names[i]]; } //重新拼接url var url = loca.origin + loca.pathname + "?" + JSON.stringify(obj).replace(/["{}]/g, "").replace(/:/g, "=").replace(/\,/g, "&"); return url; }