监听浏览器返回上一页事件

// 监听返回上一页事件
"pushState" in window.history && (
window.history.pushState({
title: document.title,
url: location.href
}, document.title, location.href),
setTimeout(function () {
window.addEventListener("popstate", function (e) {
Modal.confirm({
title: '温馨提示',
content: '返回上一页您将退出个人客户OTC账户的业务办理!',
okText: "确认",
cancelText: "取消",
onOk:() => {
history.go(-1);
},
onCancel: () => {
this.cancel;
},
});
return false;
});
}, 1000)
);
posted @ 2018-06-21 14:51  Barbie7  阅读(735)  评论(0编辑  收藏  举报