0

"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?

st_ahmed
  • 2,293
  • 1
  • 12
  • 8

1 Answers1

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