Depending on whether you need to be constant in sessions and survive in the purity of user information (cache, localStorage, etc.), you can make various decisions.
One solution might be to do something like this:
window.onpopstate = function(event) { var count = parseInt(localStorage.getItem('history-changes-count'), 10); localStorage.setItem('history-changes-count', ++count); };
Please note that onpopstate is called only after the user action, it does not work if you change the history programmatically.
More on the topic: https://developer.mozilla.org/en-US/docs/DOM/window.onpopstate
Alberto Zaccagni May 3 '13 at 12:14 2013-05-03 12:14
source share