如下:
function GetQueryString (name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i') var r = window.location.search.substr(1).match(reg) if (r != null) return (r[2]) return null }
url是 'https://www.a.com/?name=lisi';
var r = window.location.search.substr(1).match(reg);
r //["name=lisi", "", "lisi", "", index: 0, input: "name=lisi", groups: undefined]