Html5无刷新修改browser Url的方法

Ajax局部刷新可以通过html5的新特性修改browser address。

window.history表示window对象的历史记录

window.history.pushState(object, title, new_url) -- 在window.history里新增一个历史记录点

window.history.replaceState(object, title, new_url) -- 在window.history替换当前page的历史记录点

object - 可以扩展想要的object

title - 目前所有浏览器都不支持

new_url 浏览器不会检查url是否存在,只改变url,url必须同域,不能跨域

eg: original url: www.test.com

window.history.pushState({time: 'test'}, ' ', 'www.test_test.com')
发表新评论