<script>
function getUrlParam(url) {
var address = url.split('?');
if(address[0] === url){ return '';}
var arr = address[1].split('&'),len = arr.length;
var obj ={};
for (var i = 0;i<len;i++){
var ads = arr[i].split('=');
obj[ads[0]] = ads[1];
}
return obj;
}
var urlParam = getUrlParam('https://mp.csdn.net?id=666&&name=bian&&email=itdian666@163.com')
console.log(urlParam['id']);
console.log(urlParam['name']);
console.log(urlParam['email'])
</script>
获取URL地址的参数-------以object[attr]形式
最新推荐文章于 2023-04-06 14:07:30 发布