A web partial update effect in Facebook with URL changed

Possible Duplicate:
Modify the URL without reloading the page

I found that in Facebook if I click the Notes or Music links on left section, only the central section gets refreshed while the URL is changed, from www.facebook.com to www.facebook.com/Notes.

As I know, changing URL will trigger whole page reload. What magic does Facebook do to its web pages?


The magic is history.pushState().

Example

Suppose http://mozilla.org/foo.html executes the following JavaScript:

var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");

This will cause the URL bar to display http://mozilla.org/bar.html, but won't cause the >browser to load bar.html or even check that bar.html exists.


you can manipulate the browser history with javascript command like pushState/replaceState/popstate

Example:

function processAjaxData(response, urlPath){
     document.getElementById("content").innerHTML = response.html;
     document.title = response.pageTitle;
     window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath);
 }
链接地址: http://www.djcxy.com/p/70308.html

上一篇: Javascript:更新网址而不刷新页面

下一篇: Facebook中的网络部分更新效果已更改