How to catch user leaving a page and cancelling it

后端 未结 3 1292
萌比男神i
萌比男神i 2020-12-31 23:19

When a user leaves the GWT app, I would like to open a confirm dialog and offer them the choice to stay, i.e. Confirm(\"are you sure you want to leave this page\", \"yes\",

3条回答
  •  难免孤独
    2020-12-31 23:50

    You have to create a CloseHandler and register it on the Window:

    Window.addWindowClosingHandler(handler)

    EDIT: Fixed method name. See aem comment and answer.

提交回复
热议问题