html获取链接上面的参数

        $("body").click(function(){
//html获取链接上面的参数
function getQueryString(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r!=null) return r[2];else return'';
}
var type = getQueryString('type');
if(type=='1'){
alert(123);
location.replace("文件路径");
}else if(type=='2'){
alert(456);
location.replace("文件路径");
}
getQueryString('name');
});

猜你喜欢

转载自blog.csdn.net/qq_38881495/article/details/80071106