// 添加 或者 修改 url中參數的值
function UpdateUrlParam(name, val) {
var thisURL = document.location.href;
// 如果 url中包含這個參數 則修改
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;
};