轉載自:http://lazynight.me/1897.htmlhtml
折騰一下PJAX,利用HTML5的新API,實現歷史記錄的完美導入。html5
不知道你用沒用過Github,裏邊的目錄跳轉就是用html5的pushstate作的,效果很酷。git
還有一個關於web知識的宣傳網站,http://www.20thingsilearned.com/en-USgithub
你能夠完美的前進後退,而且能夠與好友分享特定頁面,實現方法?不用我說了吧。web
實現PJAX只須要如下幾點:瀏覽器
pushState(state, title, url)
– Add one history state into browser history and update the URL in the browser windowreplaceState(state, title, url)
– operates exactly like history.pushState() except that replaceState() modifies the current history entry instead of creating a new one.window.onpopstate
– A popstate event is dispatched to the window every time the active history entry changes. 不想手寫?拿來主義?網站
好吧,這裏推薦給你一個現成的文件History.js,完美支持HTML4與HTML5,url
在HTML5瀏覽器使用新API,HTML4瀏覽器繼續錨點的幹活…spa
https://github.com/balupton/History.jscode
試了一下,把wp主題給整了一個PJAX版本,效果不錯,繼續挖掘中。
想折騰的朋友,能夠開始動手了。