早睡早起,方能养生
Sleep early rise early, way to keep healthy

Javascript 浏览器返回,返回到指定页面

super
2021-09-10 18:35
views 2663

这种方式有不足之处。就是在刷新的时候,也会跳转到指定页面!!

 

慎用


$(function(){
        pushHistory();
        window.addEventListener("popstate", function(e) {

            location.href="/index.html";  // 在这里写你想要返回的页面
        }, false);
        function pushHistory() {
            var state = {
                title: "title",
                url: "#"
            };
            window.history.pushState(state, "title", "{:url('index/index')}");
        }
    });


分享
0 条讨论
top