0

I'm wondering how I can run a method when a window or tab closes. I've tried using the following...

window.onclose = () => {
  // execute function
}
window.onbeforeunload = () => {
  // execute function
}

but both of these only fire when I refresh the page not when I close it.

Any help would be very appreciated thanks!

1 Answers1

1

Not possible anymore.

Newer browsers doesn't support it anymore.

renanleandrof
  • 6,699
  • 9
  • 45
  • 67