将URL地址中的参数转换成对象
getUrl() 将参数转换成对象
getUrlK(K) 从转换后的对象中提取对应的值
var tools= {
getUrl : function(){
var obj = {};
var url = window.location.search;//获取地址栏?及
url= decodeURI(url);
var newUrl = url.slice(1)
var arr = newUrl.split("&");
arr.forEach(function (v) {
var k = v.split("=")[0];
var v = v.split("=")[1]
obj[k] = v;
})
return obj
},
getUrlK: function (k) {
var obj = this.getUrl()
return obj[k]
}
}