Alternative for jQuery beforeunload event handler

2019-09-11 17:36发布


We have a web application which accepts requests from WEB(browser)/WAP(mobile). As part of app we will display a jsp page for taking user consent. If user closes browser we need to update in db as "BROWSER TERMINATED" and redirect.

The above case is working fine with desktop/laptop. We have used jQuery's beforeunload event for identifying the tab/browser closing.

When we test the webapp in mobile the jsp is getting displayed. When the user presses the back in mobile the beforeunload event is not getting triggered. Hence, our code is not updating in db.

As an alternative I tried with jQuery mobile's pagehide event. But that too not working. Any alternative for this. Please, suggest.

标签: jquery