How to monitor the return event of Wechat browser in the H5 page?

$(function () {

    pushHistory();  
    var bool=false;  
    setTimeout(function(){  
          bool=true;  
    },1500);  
    window.addEventListener("popstate", function(e) {  
      if(bool)  
        {  
                alert("");//  
        }  
        pushHistory();  
          
}, false);  

});
when using this code to listen, click once or on this interface, and you need to click twice to return to the corresponding interface. How to solve this problem?

Mar.05,2021
Menu