1
作者:互联网
/**
* 获取url传参
* @return 一个不会为空的对象,对象的属性为参数名,值为参数值
*/
function getUrlParam() {
var param = {};
var search = location.search;
if (!search) {
return param;
}
search = search.substring(1);
var params = search.split('&');
for (var i = 0; i < params.length; i++) {
if (!params[i]) {
continue;
}
var keyValue = params[i].split('=');
if (keyValue.length > 1) {
param[keyValue[0]] = keyValue[1];
}
}
return param;
}
标签:,search,return,param,keyValue,var,params 来源: https://www.cnblogs.com/2213953937abc/p/15776426.html