想解析url 后面所携带的参数吗? 给你封装一个方法吧
function getQueryStrings () {
//location.search 返回从问号到URL末尾的所有内容
var qs = location.search.length > 0 ? location.search.substring(1) : '',
//保存数据的数组
args = {},
//取得每一项
items = qs.length > 0 ? qs.split("&") : [],
item = null,
name = null,
vaule = null,
i = 0,
len = items.length;
//逐一添加到数组中
for(var 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;
}