How to intercept window close without mismatching with location change?

112 Views Asked by At

I'm using window.onbeforeunload to intercept window close event. I've noticed that window.onbeforeunload is triggered even on location.href change and form submit.

I want to intercept only the event: "the user has closed the page". How can I do it?

**I'm open to both JavaScript or jQuery solutions.

0

There are 0 best solutions below