//禁止浏览器的回退
$(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】禁止浏览器回退
最新推荐文章于 2026-05-08 06:32:16 发布
博客给出了禁止浏览器回退的代码。通过判断浏览器是否支持 history 和 pushState,监听 popstate 事件,使用 pushState 和 forward 方法来阻止回退操作,还给出了在 IE 中必须添加的代码。
5452

被折叠的 条评论
为什么被折叠?



