Prompt confirm before Leaving edited html form

后端 未结 6 1289
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 18:50

If user tries to leave unsaved edited form, a message box pop-up

\"This page is asking you to confirm that you want to leave - data you have entered may not be saved. Le

6条回答
  •  不思量自难忘°
    2021-02-04 19:02

    You could use the "onbeforeunload" event. The syntax is as follows:

    window.onbeforeunload = function () {
        return "Your text string you want displayed in the box";
    }
    

    This event will popup that confirmation dialog that you described above asking whether or not the user truly wants to leave the page.

    Hope this helps.

提交回复
热议问题