//获取urlc参数
方法1
var urlParams = (function() { var url = window.location.href, i = url.indexOf('?'), urlParams = {}, ps, p; if (i != -1) { ps = url.substr(i+1).split('&'); for (var i = ps.length - 1; i >= 0; i--) { p = ps[i].split('='); urlParams[p[0]] = p[1]; } } return urlParams; })();
方法2:
function QueryString(QueryName) {
var name, value = '', i;
var str = location.href.toString(); //获得浏览器地址栏URL串
str = str.replace("#", "&");
var num = str.indexOf("?");
str = str.substr(num + 1); //截取“?”后面的参数串
var arrtmp = str.split("&"); //将各参数分离形成参数数组
for (i = 0; i < arrtmp.length; i++) {
num = arrtmp[i].indexOf("=");
if (num > 0) {
name = arrtmp[i].substring(0, num); //取得参数名称
value = arrtmp[i].substr(num + 1); //取得参数值
if (name.toUpperCase() == QueryName.toUpperCase()) {
return decodeURI(value).replace("#", "");
}
}
}
return "";
}
比如: http://localhost:8080/bdckfsb/per/busi/regist?caseNo=84681505070120960&type=1 方法1: urlParams.caseNo直接能取到为84681505070120960
方法2: QueryString("caseNo") 直接能取到为84681505070120960
urlParams.type直接能取到为1