当前位置:Gxlcms > JavaScript > JS如何实现禁止浏览器回退

JS如何实现禁止浏览器回退

时间:2021-07-01 10:21:17 帮助过:13人阅读

本文主要和大家分享JS如何实现禁止浏览器回退,主要以代码形式,希望能帮助到大家。

//禁止浏览器的回退
$(function() {
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.pushState('forward', null, '#');
window.history.forward(1);
});
}
window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
window.history.forward(1);
});

相关推荐:

以上就是JS如何实现禁止浏览器回退的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行