LYOA 遇到的问题及解决方案

1, js端获取url参数

function GetRequest() {
var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
if (str.indexOf("&") != -1) {
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
} else {
theRequest[str.split("=")[0]] = unescape(str.split("=")[1]);
}
}
return theRequest;
}

调用方法:
var Request = new Object();
Request = GetRequest();
var 参数1,参数2,参数3,参数N;
参数1 = Request['参数1'];
参数2 = Request['参数2'];
参数3 = Request['参数3'];
参数N = Request['参数N'];

posted on 2014-10-30 23:58  大宇牵着一只狗  阅读(240)  评论(0编辑  收藏  举报

导航