时间:2021-07-01 10:21:17 帮助过:20人阅读
function urlArgs(){
var args = {};
var query = location.search.substring(1);
var pairs = query.split('&');
for(var i = 0; i < pairs.length; i++){
var pos = pairs[i].indexOf('=');
if(pos == -1) continue;
var name = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos + 1);
value = decodeURIComponent(value);
args[name] = value;
}
return args;
}
使用方法:
代码如下:
var args = urlArgs();
var username = args.username; //yyy
var password = args.password; //zzz