-4

I have been playing around with the unload functions in Javascript, and whilst these work how I want, they're not entirely what I'm looking to implement.

How can I check if a user on my site is just browsing to another page, or if they are closing the tab/window/leaving the page entirely? I want to only trigger an event when they leave the site.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
JakeGilesPhillips
  • 163
  • 1
  • 1
  • 11

1 Answers1

1

There are plenty of answers regarding this on StackOverflow. Such like:

If this is not helping you please be more specific so we can help you out.

Community
  • 1
  • 1
JeroenE
  • 603
  • 7
  • 22
  • 1
    Thank you, that's very helpful. Glad someone gave me a pointer rather than the influx of downvotes I seem to be receiving.... – JakeGilesPhillips Dec 28 '16 at 10:31
  • 1
    No problem. Have fun coding today! As this is something you can probably Google (just like I did). If you're posting code (like what you tried, posting relevant links to post you've already tried yourself) then others see your effort and know what you tried. This makes it easier to reply and people won't vote down (mostly). If you're helped out please accept this post. :) If not, let us know. – JeroenE Dec 28 '16 at 10:36