当前位置: 软件>JavaScript软件
History.js
本文导语: History.js 很优雅的支持 HTML5 History/State APIs (pushState, replaceState, onPopState),并使之在所有浏览器上都可用。包括继续支持 data, titles, replaceState. Supports jQuery, MooTools and Prototype. 对于 HTML5 浏览器而言意味着你可以直接修改 URL 地址...
History.js 很优雅的支持 HTML5 History/State APIs (pushState, replaceState, onPopState),并使之在所有浏览器上都可用。包括继续支持 data, titles, replaceState. Supports jQuery, MooTools and Prototype. 对于 HTML5 浏览器而言意味着你可以直接修改 URL 地址。
在线演示:http://browserstate.github.io/history.js/demo/
示例代码:
(function(window,undefined){ // 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 }); // Change our States 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" })(window);
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。