//当页面关闭时是否需要提醒保存
window.isCloseHint = {};
//初始化关闭
window.addEventListener(‘beforeunload’, function (e) {
let isShow = false;
console.log(window.isCloseHint);
Object.keys(window.isCloseHint).forEach(key => {
if (window.isCloseHint[key]) {
isShow = true;
}
});
if (isShow) {
const confirmationMessage = ‘要记得保存!你确定要离开吗?’;
(e || window.event).returnValue = confirmationMessage; // 兼容 Gecko + IE
return confirmationMessage; // 兼容 Gecko + Webkit, Safari, Chrome
}
});
当页面关闭时是否需要提醒保存
最新推荐文章于 2023-06-12 16:14:49 发布