<script language="vbscript">
Function str2asc(strstr)
str2asc = Hex(asc(strstr))
End Function
Function asc2str(ascasc)
asc2str = Chr(ascasc)
End Function
</script>
<script language="javascript" type="text/javascript">
function UrlDecode(str) {
var ret = "";
for (var i=0; i<str.length; i++) {
var chr = str.charAt(i);
if (chr == "+") {
ret+=" ";
} else if(chr=="%") {
var asc = str.substring(i+1,i+3);
if (parseInt("0x"+asc)>0x7f) {
ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6)));
i+=5;
} else {
ret+=asc2str(parseInt("0x"+asc));
i+=2;
}
} else {
ret+= chr;
}
}
return ret;
}
var request = new Array();
function initRequest() {
if (window.location.search == "") return;
var qs = location.search;
qs = qs.replace("?", "");
var a = qs.split("&");
for (var i=0; i<a.length; i++) {
var arr = a[i].split("=");
request[arr[0]] = UrlDecode(a[i].slice(a[i].indexOf("=")+1, a[i].length));
}
}
function getRequest(key) {
var tmp = request[key];
if (tmp == null || tmp == undefined)
return "";
return tmp;
}
initRequest();
document.write("<br />参数 a: " + getRequest("a"));
document.write("<br />参数 b: " + getRequest("b"));
document.write("<br />参数 d: " + getRequest("c"));
document.write("<br />参数 d: " + getRequest("d"));
</script>
保存成 test.htm 后
用 test.htm?a=GO&b=%D1%C5%C1%D6%CD%F8%C2%E7&c=YES 访问看看