微信公众号监听用户返回

#微信公众号,用户监听用户点击返回
在手机微信开发者工具中可以触发,但是在手机上需要该页面进入两次以上才会触发,表示一脸懵逼
需要解决的问题就是,在用户在不同页面来回切换是,用户返回上一页会出现频繁切换

$(document).ready(function(e) {
    
    
    var counter = 0;
    if (window.history && window.history.pushState) {
    
    
        $(window).on('popstate', function () {
    
    
            window.history.pushState('index', null, '#');
            window.history.forward(1);
            window.location="{:url('')}";
        });
    }
    window.history.pushState('index', null, '#');
    window.history.forward(1);
});

猜你喜欢

转载自blog.csdn.net/weixin_44467587/article/details/111479229
今日推荐