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