How to monitor the browser refresh, close, and back behavior on PC? Then pop up the custom layer? I tried onbeforeunload method. No alert pops up.
unload cannot preventDefault, the reason is obvious when you think about it, to prevent users from being unable to close the webpage
This is what you should do:
onbeforeunload = function (){ if (unsaved) return '本次编辑未保存, 确认关闭网页?' }
unload cannot preventDefault, the reason is obvious when you think about it, to prevent users from being unable to close the webpage
This is what you should do: