Home > Web Front-end > JS Tutorial > body text

js detailed explanation on listening to browser back events

小云云
Release: 2018-02-24 14:23:49
Original
4306 people have browsed it

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(&#39;popstate&#39;, function () {
                window.history.pushState(&#39;forward&#39;, null, &#39;#&#39;);
                window.history.forward(1);
                // alert("不可回退");  //如果需在弹框就有它
                self.location="orderinfo.html"; //如查需要跳转页面就用它
            });
        }

        window.history.pushState(&#39;forward&#39;, null, &#39;#&#39;); //在IE中必须得有这两行
        window.history.forward(1);
    });
</script>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template