js阻止浏览器关闭 刷新、js监听浏览 关闭 刷新;对Alt+F4 、右键关闭 都起作用
var UnloadConfirm = {}; UnloadConfirm.MSG_UNLOAD = "数据尚未保存,离开后可能会导致数据丢失/n/n您确定要离开吗?"; UnloadConfirm.set = function(a) { window.onbeforeunload = function(b) { b = b || window.event; b.returnValue = a; return a } }; UnloadConfirm.clear = function() { fckDraft.delDraftById(); window.onbeforeunload = function() {} }; UnloadConfirm.set(UnloadConfirm.MSG_UNLOAD);
js 阻止浏览器刷新 关闭、js监听浏览 关闭 刷新 兼容IE6+ Firefox Chrome Safari
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/14025.html