Capturing result of [removed] confirmation dialog

后端 未结 3 939
清歌不尽
清歌不尽 2020-12-03 17:14

Is there a way to capture to result of the window.onbeforeunload confirmation dialog like the one below from Stack Overflow (this happens when leaving the \'Ask Question\' p

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 17:52

    You can have the exit confirmation using window.onbeforeunload but there isn't a way to find out which button the user clicked on.

    To quote an earlier response from jvenema from this thread:

    The primary purpose for the beforeunload is for things like allowing the users the option to save changes before their changes are lost.

    Besides, if your users are leaving, it's already too late [...]

提交回复
热议问题