//获取URL参数
function getUrlParam(paramName) {
var href = window.location.href;
var url = decodeURI(href);
var idx = url.indexOf("?");
var params = url.substring(idx + 1);
if (params) {
params = params.split("&");
for (var i = 0; i < params.length; i += 1) {
var param = params[i].split("=");
if (param[0] == paramName) {
//完善获取url参数的逻辑
var pArr = [];
for (var k = 1, len = param.length; k < len; k++) {
pArr.push(param[k]);
}
var p = pArr.join('=');
var idx1 = p.indexOf("#");
if (idx1 != -1) {
p = p.substring(0, idx1);
}
return p;
}
}
}
};
转载于:https://www.cnblogs.com/TanYong/p/10904215.html