//方法一
function getQueryString(key) {
var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
var result = window.location.search.substr(1).match(reg);
return result ? decodeURIComponent(result[2]) : null;
}
//方法二
function GetRequest(key) {
var urlArray = window.location.href.split("?")
var url = '?' + urlArray[1]
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest[key];
}
//方法三
function information() {
//获取链接参数
function GetRequest() {
// var url =split(window.location.href)[1]; //获取url中"?"符后的字串
var urlArray = window.location.href.split("?")
var url = '?' + urlArray[1]
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
var Request = new Object();
Request = GetRequest();
var name = Request['userName']
var userId = Request['userId']
var token = Request['token']
localStorage.setItem('username', name)
localStorage.setItem('token', token)
localStorage.setItem('userId', userId)
}
//方法一function getQueryString(key) { var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)"); var result = window.location.search.substr(1).match(reg); return result ? decodeURIComponent(result[2]) : null;}//方法二function GetRequest(key)