tags:

views:

239

answers:

2

How to get event of page refresh. i want to detect that user has refreshed page

A: 

not sure how to do it in Jquery

window.onbeforeunload = function (e) {
  var e = e || window.event;

  // For IE and Firefox
  if (e) {
    e.returnValue = 'Any string';
  }

  // For Safari
  return 'Any string';
};

https://developer.mozilla.org/en/DOM/window.onbeforeunload

Wbdvlpr
This will catch refresh, back, forward, and closing of the window
rahul
+1  A: 

On $(document).load()

  • read a var current_page from cookie
  • if it's the same as your current page, you have a refresh
  • write current page to var current_page in cookie
dyve
can u provide an example for the same
pradeep