functionGetUrlData(name){var reg =newRegExp("(^|&)"+ name +"=([^&]*)(&|$)","i");var r = window.location.search.substr(1).match(reg);if(r !=null)returnunescape(r[2]);returnnull;}
获取多个的URL参数
functionGetUrlDatas(){const url = location.search;//获取url中"?"符后的字串let theRequest =newObject();if(url.indexOf("?")!=-1){let str = url.substr(1);let strs = str.split("&");for(let i =0; i < strs.length; i ++){
theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);}}return theRequest;}
封装一些常用的工具可以给开发带来极大的便利;收集封装属于自己的工具库,是为偷懒的必要条件。获取单个的URL参数function GetUrlData(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); re