js获取url中的参数

function getUrlParam(strUrl) {
    var url, pos, urlStr, para;
    url = strUrl || window.location.href;
    pos = url.indexOf("?")
    if(pos <= 0) return;
    url = url.substring(pos + 1);
    var params = url.split("&");
    if(params == null || params.length == 0) return;
    var paramsObj = {};
    for(var i = 0; i < params.length; i++) {
        var keyvalue = params[i].split("=");
        paramsObj[keyvalue[0]] = decodeURIComponent(keyvalue[1]);
    }
    return paramsObj
}

 

posted on 2023-05-09 13:55  五官一体即忢  阅读(46)  评论(0编辑  收藏  举报

导航