js修改window对象中的url历史记录

//页面地址:http://localhost/11/account.html
//访问页面后,地址变为:http://localhost/11/account.html?type=banana
console.log(window.location.search); // 空
window.history.pushState('','', window.location.href + '&type=banana');
console.log(window.location.search); //&type=banana

点击浏览器返回按钮,返回的页面地址是:http://localhost/11/account.html

通过这种方式,修改url参数,页面不会被重新加载,可用于分页加载。

posted @ 2016-07-18 17:51  cqingt  阅读(4024)  评论(0编辑  收藏  举报