第一个页面的链接
<a href='xx.html?name="tom"'></a>
也可以是其他方式的链接,但是一定要携带参数
跳转到第二个页面,第二个页面接收参数
$.getUrlParam = function (name) {
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
let r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]); return null; //返回参数值
};
let nameResult = $.getUrlParam('name');
这样就接收到携带来的参数了