用户登录
用户注册

分享至

Html5无刷新修改browser Url的方法

  • 作者: 丶鲁伊录
  • 来源: 51数据库
  • 2021-08-06
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')
软件
前端设计
程序设计
Java相关