当前位置:Gxlcms > JavaScript > javascript怎么获取URL参数的值?

javascript怎么获取URL参数的值?

时间:2021-07-01 10:21:17 帮助过:2人阅读

function getUrlParameter(strParame){var args = new Object( );var query = location.search.substring(1);var pairs = query.split("&");for(var i = 0; i < pairs.length; i++) {var pos = pairs[i].indexOf('=');if (pos == -1) continue;var argname = pairs[i].substring(0,pos);var value = pairs[i].substring(pos+1);
            value = decodeURIComponent(value);
            args[argname] = value;
        }return args[strParame];
    }var id=getUrlParameter("id");var key=getUrlParameter("key");
    console.log(id);
    console.log(key);

以上就是javascript怎么获取URL参数的值?的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行