"beforeunload" or "onunload" event also executes when page is Refreshed. But i need to attach a Event Handler that perform only when user press the "Close" button of the Window or Tab. Is there any way?
Asked
Active
Viewed 403 times
0
-
Short answer: not possible, there is simply no such event. – Shadow The GPT Wizard Feb 16 '16 at 08:20
1 Answers
0
I guess you need to do that with onclose
event:
window.onclose = doSomthing;

Jai
- 74,255
- 12
- 74
- 103
-
[`onclose`](https://developer.mozilla.org/en-US/docs/Web/Events/close_websocket) doesn't seem suitable ... – Teemu Feb 16 '16 at 08:42
-
@Teemu i was referring to this [onclose event.](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onclose) – Jai Feb 16 '16 at 08:49