robint

Html5 新增history对象的两个方法:history.pushState()和history.replaceState(),方法执行后,浏览器地址栏会变成你传的url,而页面并不会重新载入或跳转。history.pushState(statetitleurl):通过设置statetitleurl创建新的浏览器历史记录。

例如:

var state = { \'page_id\': 1, \'user_id\': 5 };

var title = \'Hello World\';

var url = \'hello-world.html\';

history.pushState(state, title, url);

 

history.replaceState(statetitleurl):通过设置statetitleurl修改当前浏览器历史记录。

 

注意:为了安全性,URL必须保持与当前URL同一个域。

分类:

技术点:

相关文章: