js获取url参数
作者:互联网
https://www.cnblogs.com/cnyg/?id=1
var id= request('id');
function request(paras) {
var url = location.href;
var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
var paraObj = {}
for (var i = 0; j = paraString[i]; i++) {
paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
}
var returnValue = paraObj[paras.toLowerCase()];
if (typeof (returnValue) == "undefined") {
return "";
} else {
return returnValue;
}
};
标签:paraObj,url,js,substring,参数,returnValue,var,id 来源: https://www.cnblogs.com/cnyg/p/13176855.html