JavaScript, browsers, window close - send an AJAX request or run a script on window closing

前端 未结 9 890
梦毁少年i
梦毁少年i 2020-11-22 04:40

I\'m trying to find out when a user left a specified page. There is no problem finding out when he used a link inside the page to navigate away but I kind of need to mark up

9条回答
  •  情深已故
    2020-11-22 05:20

    Im agree with Felix idea and I have solved my problem with that solution and now I wanna to clear the Server Side solution:

    1.send a request from client side to server

    2.save time of the last request recived in a variable

    3.check the server time and compare it by the variable of last recived request

    4.if the result is more than the time you expect,start running the code you want to run when windows closed...

提交回复
热议问题