禁用移动端回退功能

这里的方法用于防止用户通过手机端的后退,再次回到之前的页面

//这里的方法用于防止用户通过手机端的后退,再次回到之前的页面
if(window.history && window.history.pushState){
    $(window).on('popstate',function () {
        window.history.pushState('forward',null,'#');
        window.history.forward(1);
    })
}
window.history.pushState('forward',null,'#');
window.history.forward(1);

 

posted @ 2019-04-16 15:11  墨恒  阅读(563)  评论(0编辑  收藏  举报