javascript js 取得网页的url中带的参数 js 获取 url 参数



function getUrlParmas() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        if (str.indexOf("&") != -1) {
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
            }
        } else {
            theRequest[str.split("=")[0]] = decodeURIComponent(str.split("=")[1]);
        }
    }
    return theRequest;

}


function getParam(name){


    return getUrlParmas()[name];
}

猜你喜欢

转载自blog.csdn.net/u011249282/article/details/49866617
今日推荐