Home > Article > Web Front-end > How to disable browser rollback in JS
This article mainly shares with you how to prohibit browser rollback in JS, mainly in the form of code. I hope it can help everyone.
//禁止浏览器的回退 $(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); });
Related recommendations:
How to prevent the browser from returning to the previous page by clicking the back button?
Use js to disable the browser back button
JS tips: disable the browser back button
The above is the detailed content of How to disable browser rollback in JS. For more information, please follow other related articles on the PHP Chinese website!