0

I'm trying to figure it out this problem, already found similar posts on this site and over the web and most of these responses are to use: unload event, which I use it right now, but it executes when the user refresh and close the page.

I use the Beacon API to send data to the server inside the unload event, so that's not a problem.

All I need is send data when the user closes the page.

Does anyone have any idea to acomplish this? Thanks.

Roel Magdaleno
  • 337
  • 5
  • 12
  • Possible duplicate of [Run JavaScript code on window close or page refresh?](https://stackoverflow.com/questions/13443503/run-javascript-code-on-window-close-or-page-refresh) – esqew Oct 03 '18 at 00:37
  • @esqew might not be a duplicate, as he doesn't want the unload event to run when page is refreshed – Jerdine Sabio Oct 03 '18 at 00:39
  • There's a comment on one of the answers that might help; you could identify the refresh through local storage/cache and when they were last loaded https://stackoverflow.com/questions/14063012/detect-refresh-browser-for-unload-beforeunload-when-browser-closed – Jerdine Sabio Oct 03 '18 at 00:49
  • Thank you, I'll take a look at the responses – Roel Magdaleno Oct 03 '18 at 02:30

0 Answers0