开发者

jQuery History.js:about statechange event trigger due to browser forward and backward button

开发者 https://www.devze.com 2023-02-27 22:13 出处:网络
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

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开发者_Python百科, state: st}, null, "?state="+st);

So how can I achieve this goal?


There is a discussion about this here: https://github.com/browserstate/history.js/issues/47

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号