更新时间:2022-11-04 13:00:18
Facebook 正在使用 HTML5 中的历史 API.从这篇博文中,您可以看到这是如何工作的.基本上,他们正在调用如下所示的方法来更改 url,而无需重新加载页面.
Facebook is using the history api in HTML5. From this blog post you can see how this works. Basically they are making calls like the one below to change the url without reloading the page.
window.history.pushState("object or string", "Title", "/new-url");
这是关于它的 HTML5 工作草案规范:http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-location-interface
Here is the HTML5 working draft spec about it: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-location-interface
遗憾的是,IE9 不支持此 api.新版本的 Chrome 和 FF 完全支持.
Sadly, IE9 does not support this api. New versions of Chrome and FF have full support.