How to detect browser closing?

后端 未结 6 1570
故里飘歌
故里飘歌 2020-11-28 13:48

In my web app, when a user logs in, I add his Id to a vector of valid Ids in the servlet, when he logs out, I remove his Id from the vector, so I can see how many current us

6条回答
  •  粉色の甜心
    2020-11-28 14:03

    in JavaScript you can use the onbeforeclose event to pass a call back to the server when the user closes the browser.

    I typically use a synchronous Ajax call to do this.

提交回复
热议问题