Hello @kartik,
Try the onbeforeunload event: It is fired just before the page is unloaded. It also allows you to ask back if the user really wants to leave.
Alternatively, you can send out an Ajax request when he leaves.
Hope it helps!!
To learn about Java, enroll with Java certification course now.
Thank you!!