This article mainly shares with you the detailed explanation of js about monitoring browser back events. I hope the code in this article can help everyone.
Upload the code directly (can be used directly)
<script> $(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("不可回退"); //如果需在弹框就有它 self.location="orderinfo.html"; //如查需要跳转页面就用它 }); } window.history.pushState('forward', null, '#'); //在IE中必须得有这两行 window.history.forward(1); }); </script>
Related recommendations:
JS example of monitoring browser tab page switching
How to monitor the browser closing action in js and wait online_html/css_WEB-ITnose
Youdao JavaScript monitoring browser problem_javascript skills
The above is the detailed content of js detailed explanation on listening to browser back events. For more information, please follow other related articles on the PHP Chinese website!