-2

how to code a code to detect when user is close their browser and show up a pop up message ? but if press F5 or move to other page ,dont let it work , only work when browser closing

J.WCT
  • 92
  • 9
  • If you want to do this by JS / Jquery as your title suggest, why have you tagged it with php? - Further more, "Doesn't work" isn't a very informative problem statement. – Epodax May 24 '17 at 11:22
  • 2
    Possible duplicate of [Detect Close windows event by Jquery](https://stackoverflow.com/questions/16707249/detect-close-windows-event-by-jquery) – zuluk May 24 '17 at 11:46

1 Answers1

0

This is not possible, because JavaScript runs within your browser. So it cannot detect your click closing the browser.

However it is possible to check if F5 was pressed, but this was not your main aim. how to detect an F5 refresh keypress event in jquery?

zuluk
  • 1,557
  • 8
  • 29
  • 49