views:

58

answers:

2

using jquery, how can you distinguish between refreshing vs. navigating away from the current URL ?

+3  A: 

Not you can't. Unless the navigation is triggered by an event within the current page/window.

See the JQuery events doc for more info: http://docs.jquery.com/Events

There could be some other ways, using cookies or other means for you to do the detection though.

To Add:

I found this alternative, just javascripts and cookies.

o.k.w
Georg
@gs: Without javascript is possible i guess, didn't spend much thought on it. But cookies seems like something convenient.
o.k.w
+2  A: 

Don't think there is a Javascript only or Jquery specific way of doing this... but check out this article on how it can be done using hidden variables or cookies. Looks like it won't catch 100% but it might be a start.

beggs
@beggs: hah, we found the same sample. +1 :)
o.k.w