Url change triggers statechange; hash change triggers hashchange. But both are stored in back button history. How to exclude hashchange events?
use:
location.replace("#hash")
It worked fine for me until I found that it doesn’t work on IOS Chrome. In which case, use:
history.replaceState(undefined, undefined, "#hash")
history.replaceState() operates exactly like history.pushState() except that replaceState() modifies the current history entry instead of creating a new one.
Remember to keep the #
or the last part of the url will be altered.