function getUrlParams() {
var search = window.location.search;
// 写入数据字典
var tmparray = search.substr(, search.length).split("&");
var paramsArray = new Array;
if (tmparray != null) {
for (var i = ; i < tmparray.length; i++) {
var reg = /[=|^==]/; // 用=进行拆分,但不包括==
var set1 = tmparray[i].replace(reg, '&');
var tmpStr2 = set1.split('&');
var array = new Array;
array[tmpStr2[]] = tmpStr2[];
paramsArray.push(array);
}
}
// 将参数数组进行返回
return paramsArray;
} // 根据参数名称获取参数值
function getParamValue(name) {
var paramsArray = getUrlParams();
if (paramsArray != null) {
for (var i = ; i < paramsArray.length; i++) {
for (var j in paramsArray[i]) {
if (j == name) {
return paramsArray[i][j];
}
}
}
}
return null;
} function UrlDecode(zipStr) {
var uzipStr = "";
for (var i = ; i < zipStr.length; i++) {
var chr = zipStr.charAt(i);
if (chr == "+") {
uzipStr += " ";
} else if (chr == "%") {
var asc = zipStr.substring(i + , i + );
if (parseInt("0x" + asc) > 0x7f) {
uzipStr += decodeURI("%" + asc.toString() + zipStr.substring(i + , i + ).toString());
i += ;
} else {
uzipStr += AsciiToString(parseInt("0x" + asc));
i += ;
}
} else {
uzipStr += chr;
}
} return uzipStr;
} function StringToAscii(str) {
return str.charCodeAt().toString();
} function AsciiToString(asccode) {
return String.fromCharCode(asccode);
}
使用getParamValue(参数名)获得值
使用UrlDecode(中文) 可以解密成中文