The mobile terminal controls Android, ios, and browsers to go back to the specified page

Back view: When making a WeChat mall on the mobile terminal, there is a membership upgrade page. Click on the upgrade to make WeChat payment. After the payment is successful, it will jump to a customized payment success page. At this time, click the return of the browser to return. Go to the payment page of WeChat, and then prompt that the payment has been successful. Generally speaking, you need to go back to the upgrade page or home page, then you need to monitor the return event of the browser.

//Add the following code to the custom page for successful payment

$(function () {
  pushHistory();
  var bool = false;
  setTimeout(function () {
    bool = true;
  }, 1500);
  window.addEventListener("popstate", function (e) {
    if (bool) {
      window. history.go(-2); //This is equivalent to returning twice in a row, skipping the payment page to get history
    }
  }, false);
  function pushHistory() {
    var state = {
      title: "title",
      url: "# "
    };
    window.history.pushState(state, "title", "#");
  }
});

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324973022&siteId=291194637