function getParameter(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) { return decodeURI(r[2]) } return null } 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参数并返回新的URL
最新推荐文章于 2022-05-27 16:22:54 发布