0

I want to display a popUP for responsive device users if they are going to close the browser or refresh the browser in their android or iOs devices. I tried using Window: beforeunload event function but this event function always display a standard message. Can I hide it and write my own custom message or POPUP ? Basically I want to show a popup when a user tries to close or refresh the browser in responsive iOS and android devices.

Any pointers in this regards will be very helpful.

Thank you

  • I referred this help link and tried implementing also but . I am not able to implement a custom message in popup – Ambika Tewari Jan 08 '20 at 07:41
  • yepp @insertusernamehere and found the same. – Ambika Tewari Jan 08 '20 at 08:04
  • There's no way you can show your own pop-up in an (before)unload eventhandler. All the code in the handler must be synchronous, any async call will continue to terminate the page closing process. You need to change the design, ex. you can send some data to the server even [after the page has been closed](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon), store that data to the database, and on the next visit of the user, populate the page with the old, unsaved data. – Teemu Jan 08 '20 at 08:16

0 Answers0