How can I override the OnBeforeUnload dialog and replace it with my own?

前端 未结 11 2001
一生所求
一生所求 2020-11-21 06:14

I need to warn users about unsaved changes before they leave a page (a pretty common problem).

window.onbeforeunload=handler

This works bu

11条回答
  •  悲&欢浪女
    2020-11-21 06:58

    What about to use the specialized version of the "bind" command "one". Once the event handler executes the first time, it’s automatically removed as an event handler.

    $(window).one("beforeunload", BeforeUnload);
    

提交回复
热议问题