在html后面拼接字符串后页面的跳转

我就举一个简单的栗子,主要目的是实现页面跳转时后面获取的参数

<div class="active">
            点击我可以跳转
        </div>

样式就随便写一下   

之后主要是后面的 js

function jump(res){
            console.log(window.location);
            var mpt =window.location.search.substr(7,1);
            console.log(mpt);
            var opt=window.location.search.substr(-1);
            console.log(window.location.search.substr(-1));
            $(".active").click(function(){
                window.location.href="xxxxx.html?opt=" + opt +"&mpt="+mpt
                
            })
        }
            jump();

之后你所跳转的页面也就加上了后面的参数

猜你喜欢

转载自www.cnblogs.com/rose-1121/p/10757520.html
今日推荐