早睡早起,方能养生
Sleep early rise early, way to keep healthy

JS获取url参数

super
2019-11-22 12:01
views 3027

function getQueryString(name)
{
    const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    const urlObj = window.location;
    var r = urlObj.href.indexOf('#') > -1 ? urlObj.hash.split("?")[1].match(reg) : urlObj.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}
//获取参数 code:
alert(getQueryString("code"));

 

 



分享
0 条讨论
top