$(function(){
// Prepare
var History = window.History; // Note: We are using a capital H instead of a lower h
if ( !History.enabled ) {
// History.js is disabled for this browser.
// This is because we can optionally choose to support HTML4 browsers or not.
return false;
}
// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
var State = History.getState(); // Note: We are using History.getState() instead of event.state
History.log(State.data, State.title, State.url);
});
});
我正在尝试使用 history.js 作为跟踪状态更改(前进和后退按钮)的一种方式,并且似乎只有当我打开一个新的浏览器窗口并从那里工作时才会触发 window.statechange。记录最初的前进和后退事件,但不记录后续事件。
任何想法为什么会这样?