Javascript/jQuery detect hash change only on browser back/forward button click

Is it possible to detect the hashchange only on a browser history change (i.e. Back or Forward button)?

I have seen the onBeforeUnload event, but this event does not fire on hash change, as the window is not unloading.

The hashchange event obviously fires anytime the hash changes. Any fix? Preferably without a plugin. I have seen the jQuery history plugin, but am looking for the simplest solution.

Thanks for the help.


Take a look at the window.onhashchange event.

It is not currently supported in all browsers however. Take a look at the BA jQuery Hash Change Plugin here. It may work, if you choose to use a plugin in the end.

I hope this helps!

I ended up marking a flag whenever my navigation was triggered, and if the flag was marked, the hashChange event would ignore it, otherwise it would handle it as if it was a back/forward event.

Need Your Help

Aggregate function duplicates items in ng-repeat on page refresh. Need to figure out how to stop the duplication. Angularjs Mongodb mongoose

angularjs node.js mongodb mongoose angularjs-filter

I have items in a collection that run through this aggregate to find them with an average rating and to find them when they have not yet been commented on / rated yet.

Making Only Specific Functions and Variables Available in PHP

php function variables constants

I want to make a programming environment. I will explain it with an example.