获取code时,截取回调url中的code

/**
 * 获取链接中的code
* key 为键,key=code/
auth_code(wx:code=asfgasg54654,ali:auth_code=ag6465a4s6g5d)
**/
function getUrlValue(key){
    var url = location.search;
    var theRequest = new Object();
    if (url.indexOf("?") != -1)
    {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++)
        {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    var value = theRequest[key];
    userCode = value;
    return value;
}
posted @ 2021-12-31 12:02  冷闲欧巴  阅读(195)  评论(0)    收藏  举报