How to show the “Are you sure you want to navigate away from this page?” when changes committed?

前端 未结 17 1960
深忆病人
深忆病人 2020-11-22 02:11

Here in stackoverflow, if you started to make changes then you attempt to navigate away from the page, a javascript confirm button shows up and asks: \"Are you sure you want

17条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-22 02:59

    What you want to use is the onunload event in JavaScript.

    Here is an example: http://www.w3schools.com/jsref/event_onunload.asp

提交回复
热议问题