Skip to content

js工具类

获取url参数

js
function getUrlParams(key) {
    var query = window.location.search.substring(1);
    if (query) {
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == key) {
                return pair[1];
            }
        }
    }
    return "";
}