2020.10.30
从url获取值
//当前url地址栏 file:///C:/Users/admin/Desktop/test.html?id=2 function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); console.log(window.location.search)//?id=2 var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; }