js构建url参数

function build_params(param, value){
    var search = '';
    var params_str = window.location.search.substr(1);
    params_str.split('&').forEach(function(n){
        if (n && n.substr(0, param.length) != param) {
            search += n + '&';
        }
    })
    if (value !== '') {
        search += param + "=" + value;
    }
    window.location.href = "?" + search;
}