//查询链接字符串函数
//?q=javascript&num=10
function getQueryStringAzgs(){
var qs = location.search.length > 0 ? location.search.substring(1) : "",
args ={},
items = qs.length ? qs.split("&") : [],
item = null,
namee = null,
value = null,
i = 0,
len = items.length;
for(i=0;i<len;i++){
item = items[i].split("=");
name = decodeURIComponent(item[0]);
value = decodeURIComponent(item[1]);
if(name.length){
args[name] = value;
}
}
return args;
}
var args = getQueryStringAzgs();
console.log(args["q"]);//javascript
console.log(args["num"]);//10
查询链接字符串函数
最新推荐文章于 2020-11-18 10:17:06 发布