How can I get close event of window? Tried onbeforeunload. But it is triggering for refresh too. How can I detect refresh and execute my script only in window close. Or is there any solution on server side to detect browser window close. I am using php
Asked
Active
Viewed 66 times
0
-
2I don't believe you can differentiate between close and refresh. – Turnip Jan 16 '18 at 11:55
-
^^ That, and there is definitely no way to detect a browser event on the server, unless the browser *tells* the server. – Reinstate Monica Cellio Jan 16 '18 at 11:56
-
1You can use a trick like a ping send by your JS to the server each X seconds, save this time, and with something like a cron, check if (time_save + X seconds < time()). – Obzi Jan 16 '18 at 11:59