防止点浏览器返回按钮,返回上一页的JS方法

来源:互联网 发布:企业数据备份管理制度 编辑:程序博客网 时间:2024/05/14 16:11
希望最终停在B页,不想点B页浏览器返回按钮,返回到A页,则在A页加:
<script>
    $(document).ready(function(e) {
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.pushState('forward', null, '#');
window.history.forward(1);
//$("#label").html("第" + (++counter) + "次单击后退按钮。");
});
}
window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
window.history.forward(1);

});

</script>

0 0
原创粉丝点击