获取http://localhost:8888/pages/bus/bus_apply.html?name=2019&gradeTarget=03的参数值gradeTarget
1.js
var HRui = {
GetQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = decodeURIComponent(window.location.search).substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
},
}
2.使用
var gradeTarget= HRui.GetQueryString('gradeTarget');
console.log(gradeTarget)
网友评论