//获取URL参数
function getUrlVars(url){
var vars = [];
var baseUrl =''
var index = url.indexOf('?')
if(index!== -1){
baseUrl = url.slice(0,index)
}
var queryArr = url.slice(index +1).split('&');
for(var i =0;i
var hashIndex =queryArr[i].indexOf('=')
var key =queryArr[i].slice(0,hashIndex)
var value =decodeURIComponent(queryArr[i].slice(hashIndex+1,hashIndex.length))
vars.push(key)
vars[key] =value
}
return {url :baseUrl,query :vars}
}
var url ='http://wwww.baidu.com?id=123&sed=qere&parter_id=333'
getUrlVars(url)//{url:http://wwww.baidu.com,query : ["id", "sed", "parter_id", id: "123", sed: "qere", parter_id: "333"
网友评论