在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();

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

 

posted @ 2019-04-23 17:09  wei小然  阅读(1164)  评论(0编辑  收藏  举报