微信公众号监听返回事件

 $(function(){
        if (window.history && window.history.pushState) {
            window.addEventListener("popstate", function (e) {  //回调函数中实现需要的功能
                // alert("我监听到了浏览器的返回按钮事件啦");
                window.location.href = 'index.html?id=' + F_EmployeeId + '&AppId=' + localStorage.getItem('AppId');  //在这里指定其返回的地址
            }, false);

            !function () {

                var state = {
                    title: "title",
                    url: "#"
                };
                window.history.pushState(state, "url", "#");
            }();

        }

    });

posted @ 2019-11-26 14:24  零碎沉默  阅读(1849)  评论(0编辑  收藏  举报