Solution onbeforeunload not working on IOS devices

Here let have a look on issue thet the above event window.onbeforeunload is not working on IOS devices like Ipad, i phone, and working very well with andrios and web browser on windows but its stucks with safari, to over come that situtation we have a event for ios devices pagehide event so in code base we need to check if the device is IOS then we need to fire page hide event (IOS pagehide event), and if the browser is wondows then we normally fires onbeforeunload event, also let understand what these event will do.

window.onbeforeunload and window.onunload is not working on IOS devices

onbeforeunload / onhide event

This event allows you to display a message in a confirmation dialog box to inform the user whether to stay or leave the current page.

The standard message displayed in the confirmation dialog varies across different web browsers. Typically, it resembles “Are you sure you want to leave this page?”This message cannot be eliminated unless you invoke preventDefault() on the event.

Solution to onbeforeunload on IOS device

Further reading