//防止页面后退
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
history.pushState(null, null, document.URL);
});
js禁止浏览器的回退事件
最新推荐文章于 2024-06-23 04:15:59 发布
本文介绍如何使用JavaScript的`history.pushState`和`popstate`事件来防止用户通过浏览器历史记录回退到当前页面。通过监听popstate事件,每当用户试图后退时,页面会自动刷新并保持当前URL。
摘要由CSDN通过智能技术生成