您的位置:首页 > Web前端 > JavaScript

js监听浏览器后退事件

2018-02-23 09:39 232 查看
直接上代码(可直接使用)<script>
$(document).ready(function (e) {
var counter = 0;
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.pushState('forward', null, '#');
window.history.forward(1);
// alert("不可回退"); //如果需在弹框就有它
self.location="orderinfo.html"; //如查需要跳转页面就用它
});
}

window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
window.history.forward(1);
});
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: