function getQueryStringArgs() {
// 取得要查询的字符串并去掉开头的问号
var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
args = {},
items = qs.length ? qs.split("&"): [],
item = null,
name = null,
value = null,
// 在for 循环中使用
i = 0,
len = items.length;
// 逐个将每一项目添加到args对象中
for (i; i < len; i++) {
item = items[i].split("=");
name = decodeURIComponent(item[0]);
value = decodeURIComponent(items[1]);
if (name.length) {
args[name] = value
}
}
console.log(args);
return args;
}
getQueryStringArgs()
最新推荐文章于 2019-09-26 14:57:50 发布