浏览器回退按钮问题

1、js监听回退事件

(function (window, location) {
            history.replaceState(null, document.title, location.pathname + "#!/stealingyourhistory");

            history.pushState(null, document.title, location.pathname);

            window.addEventListener("popstate", function () {

                if (location.hash === "#!/stealingyourhistory") {

                    history.replaceState(null, document.title, location.pathname);

                    setTimeout(function () {
                         $('.dialog').css('display', 'block');
                    }, 0);
                }
            }, false);
        }(window, location));

2、从详情页回退到列表页,并刷新列表页

列表页中添加以下代码,缺点:每次回退都会刷新页面,导致进度条从头开始
window.onpageshow = function(event){ if (event.persisted) { window.location.reload(); } }
原文地址:https://www.cnblogs.com/rommel0618/p/7941828.html