代码
//得到地址栏参数
getQueryString:function(paras) {
var url = location.href;
var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
var paraObj = {}
for (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") {
console.log(1)
return "";
} else {
var decodeString = "";
try {
decodeString = decodeURIComponent(returnValue);
}catch(e){
decodeString = returnValue;
}
return decodeString;
}
/* var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return decodeURI(r[2]); return null;*/
},
网友评论