js获取url中的参数....正则匹配

location.href = '/login.html?next=/user_center_info.html';

// 获取url路径参数
get_query_string: function(name){
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return decodeURI(r[2]);
    }
    return null;
},
// 跳转页面
var return_url = this.get_query_string('next');
if (!return_url) {
    return_url = '/index.html';
}
location.href = return_url;

猜你喜欢

转载自blog.csdn.net/qq_42091922/article/details/86079630