developed in Wechat official account, listening returned event page B is listening page
C page without adding listening event
page flow AME-> BMY-> C
when you click on Wechat"s official account to return, Clam-> flashed BMIT-> A will jump twice
this is Wechat"s official account listening code:
function backHistory(backUrl) {
let state = {
title: "title"
};
window.history.pushState(state, state.title, window.location.href);
window.addEventListener("popstate", function(e) { //
if(backUrl == undefined) {
history.go(-1);
} else {
if(backUrl == "home") {
if(wx != undefined) {
wx.closeWindow();
}
} else {
location.href=backUrl; //
}
}
}, false);
}