function getQueryString(name)
{
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
//獲取URL中code參數
//http://xxx.xxx.com?code=123
var code = getQueryString('code');
//now code = 123
參考:
https://blog.csdn.net/qq_36947128/article/details/78594462
https://www.cnblogs.com/c9999/p/5852597.html
https://www.runoob.com/w3cnote/js-get-url-param.html