JS 获取URL 后面的参数

function GetRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]); } } if (theRequest == undefined || theRequest == null) { theRequest == ""; } return theRequest; } //解决中文乱码 function getParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return decodeURI(r[2]); //对参数进行decodeURI解码 return null; } https://localhost:5001/script/selectbox/template/tableItem.html?nos%20=JT201600723&date=2016-10&company=母公司&curreny=人民币(CNY)&status=已审计&wd=实际 %20 为空格 传参的时候注意点即可

相关文章