Differentiate Back/Forward click and History.pushState/replaceState in statechange event
Asked Answered
F

2

9

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.

Forequarter answered 27/2, 2012 at 11:27 Comment(0)
B
1

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.

Boxcar answered 22/5, 2012 at 15:32 Comment(0)
C
1

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.

Clea answered 7/11, 2012 at 6:33 Comment(1)
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.