现在可以在Chrome,Safari,Firefox 4+和Internet Explorer 10pp4 +中完成此操作!
例:function processAjaxData(response, urlPath){
document.getElementById("content").innerHTML = response.html;
document.title = response.pageTitle;
window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath);
}
然后,您可以使用window.onpopstate检测后退/前进按钮导航:window.onpopstate = function(e){
if(e.state){
document.getElementById("content").innerHTML = e.state.html;
document.title = e.state.pageTitle;
}};
有关操纵浏览器历史记录的更深入了解,请参阅此MDN文章。