/**
* [通过参数名获取url中的参数值]
* 示例URL:http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明
* @param {[string]} queryName [参数名]
* @return {[string]} [参数值]
*/
function GetQueryValue1(url, queryName) {
var reg = new RegExp('(^|&)' + queryName + '=([^&]*)(&|$)');
try{
var search = url.split('?')[1];
if (search) {
var r = search.match(reg);
if (r !== null) {
return decodeURIComponent(r[2]);
}
}
}catch(e){
//TODO handle the exception
}
return '';
}
参考:https://www.cnblogs.com/yeminglong/p/12106857.html