I am using History.js plugin which support HTML 5 pushState and replaceState. The statechange is triggered when a user click back/forward button and when pushState/replaceState is used. I need to check whether statechange event is triggered from back/forward button or by using pushState/replaceState methods.
Differentiate Back/Forward click and History.pushState/replaceState in statechange event
Asked Answered
I haven't looked at History.js, but Ben Alman's jQuery BBQ (Back-Button & Queue Library) is an excellent library that contains a 'hashchange' event. This might be different than what you are trying to do, though, since his library relies on hashtags in a URL, and not a browser's internal statechange. He's also got a repo on GitHub for hashchange.
According to a discussion on the GitHub by the author, it is impossible to do that (from a year ago, can't find the link again). Your option really is to look for some kind of a workaround like breadcrumbs etc.
Did you ever find that link? I think it was possible even in 2011. See for example the code I gave in answer to another question. –
Puce
© 2022 - 2024 — McMap. All rights reserved.