首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

如何用JS获取获取浏览器地址栏参数

2013-04-05 
怎么用JS获取获取浏览器地址栏参数?http://www.jiayou.in/Login.html#access_token4c65b3ce696b92e5e5311

怎么用JS获取获取浏览器地址栏参数?
http://www.jiayou.in/Login.html#access_token=4c65b3ce696b92e5e5311b6b3c42b8af&expires_in=3600

我想在JS中判断access_token这个值存不存在?
怎么样获取他的值啊?
[解决办法]


function getParam(paramName) {
    paramValue = "";
    isFound = false;
    if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
        arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&");
        i = 0;
        while (i < arrSource.length && !isFound) {
            if (arrSource[i].indexOf("=") > 0) {
                if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) {
                    paramValue = arrSource[i].split("=")[1];
                    isFound = true;
                }
            }
            i++;
        }
    }
    return paramValue;
}

热点排行