jQuery History.js:关于浏览器前进后退按钮触发的statechange事件
我刚刚将 History.js 集成到我的 jquery Ajax 应用程序中,但我找不到一种方法区分由于我自己的代码中的 History.pushState 以及由于用户单击浏览器后退和前进按钮而导致的 statechange 事件(在这两种情况下都会触发事件)。
History.Adapter.bind(window,'statechange',function(){
var State = History.getState(); //
if (??????) // should be true only when statechange was triggered due to user clickin on Back or Forward button
showHistoryContent(State.data.historyObj);
});
...........
st++
History.pushState({historyObj:dto, state: st}, null, "?state="+st);
那么我怎样才能实现这个目标呢?
I just integrated History.js in my jquery Ajax application but I could not find a way how to differentiate statechange event due to History.pushState in my own code and due to user clicking on Browser back and forward button (in both cases the event gets triggered).
History.Adapter.bind(window,'statechange',function(){
var State = History.getState(); //
if (??????) // should be true only when statechange was triggered due to user clickin on Back or Forward button
showHistoryContent(State.data.historyObj);
});
...........
st++
History.pushState({historyObj:dto, state: st}, null, "?state="+st);
So how can I achieve this goal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有一个关于这个的讨论:
https://github.com/browserstate/history.js/issues/47
There is a discussion about this here:
https://github.com/browserstate/history.js/issues/47