History.js在所有瀏覽器中均優雅地支持HTML5歷史記錄/狀態API(pushState,replaceState,onPopState)。
看看演示使用here
例子:
History.pushState({state:1}, "State 1", "?state=1"); // logs {state:1}, "State 1", "?state=1"
History.pushState({state:2}, "State 2", "?state=2"); // logs {state:2}, "State 2", "?state=2"
History.replaceState({state:3}, "State 3", "?state=3"); // logs {state:3}, "State 3", "?state=3"
History.pushState(null, null, "?state=4"); // logs {}, '', "?state=4"
History.back(); // logs {state:3}, "State 3", "?state=3"
History.back(); // logs {state:1}, "State 1", "?state=1"
History.back(); // logs {}, "Home Page", "?"
History.go(2); // logs {state:3}, "State 3", "?state=3"
大約一年前,History.js不再維護。請參閱https://github.com/browserstate/history.js/blob/master/README.md – King 2018-01-08 04:11:03