0

I have a window.unbeforeunload event and I don't want to fire it if user clicks on logout.

Is there a way to get a request URL in JS before doing its action? My idea is to check if, for example, url is https://www.example.com/logout then don't show alert box in window.unbeforeunload event.

harunB10
  • 4,823
  • 15
  • 63
  • 107
  • 1
    `clicks on logout` - put a click even handler on that logout element - set a flag when it's clicked ... check the flag in `beforeunload` handler ...messy, but quick – Bravo Aug 18 '21 at 10:33
  • 2
    Related: [How can I get the destination URL for the onbeforeunload event?](https://stackoverflow.com/questions/1686687/how-can-i-get-the-destination-url-for-the-onbeforeunload-event) – Ivar Aug 18 '21 at 10:35

0 Answers0