// 添加 或者 修改 url中参数的值
function UpdateUrlParam(name, val) {
var thisURL = "{$query}";
if (thisURL.indexOf(name+'=') > 0) {
var v = getUrlParam(name);
if (v != null) {
// 是否包含参数
thisURL = thisURL.replace(name + '=' + v, name + '=' + val);
}
else {
thisURL = thisURL.replace(name + '=', name + '=' + val);
}
} else {
if (thisURL.indexOf("?") > 0) {
thisURL = thisURL + "&" + name + "=" + val;
}
else {
thisURL = thisURL + "?" + name + "=" + val;
}
}
location.href = thisURL;
};
function getUrlParam(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}