//*************************************
//读取Url中参数的函数
//*************************************
function getUrlParameter(seekParameter) {
var url = location.href;
var parameters = url.substr(url.indexOf("?") + 1);
var parameterItems = parameters.split("&");
var parameterName;
var parameterVar = "";
for (i in parameterItems) {
parameterName = parameterItems[i].split("=")[0];
parameterVar = parameterItems[i].split("=")[1];
if (parameterName == seekParameter) {
return (parameterVar);
}
}
return "";
}
//*************************************
//修改Url中参数的函数
//*************************************
function setUrlParam(url, param, v) {
var re = new RegExp("(\\\?|&)" + param + "=([^&]+)(&|$)", "i");
var m = url.match(re);
if (m) {
return (url.replace(re, function ($0, $1, $2) { return ($0.replace($2, v)); }));
}
else {
if (url.indexOf('?') == -1)
return (url + '?' + param + '=' + v);
else
return (url + '&' + param + '=' + v);
}
}