Wechat browser return key how to prevent him from returning to the previous interface

Wechat browser returns how the key prevents him from returning to the previous interface, and then

clipboard.png

Apr.20,2021

call Zhang Xiaolong to change the source code


maybe it's not called back,. It's different from webview. Check for yourself

window.addEventListener("back", e => e.preventDefault())

you can specify the url, code to jump when you click the back button as follows:

      pushHistory();
      window.addEventListener("popstate", function(e) {
          window.location.href='aaaaa.html';//
      }, false);

      function pushHistory() {
        var state = {
            title: "title",
            url: "-sharp"
        };
        window.history.pushState(state, "title", "-sharp");
      }

implementation principle reference: HTML5 pushstate, popstate operation history

Menu