1、 window.addEventListener
window.addEventListener(
"popstate",
function (e) {
alert("你点了返回键1");
},
false
);
2、window.onpopstate
window.onpopstate = function (e) {
alert("你点了返回键2");
};
禁用返回键完整代码
window.addEventListener("popstate", function () {
window.history.pushState(null, null, "#");
});