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

js监听浏览器后退事件

2017-09-08 11:20 218 查看
$(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("不可回退");
});
}

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