url的hash和html5的history

通过以下可以改变浏览器中的url

跳转到home路径下:

location.hash='home'

跳转到about路径下:

history.pushState({},'','about')

向上回退:

history.back()

向前进:

history.forward()

 

使用test路径替换之前的url,不能回退

history.replaceState({},'','test')

 

 

posted @ 2022-11-16 20:57  Mr_sven  阅读(14)  评论(0编辑  收藏  举报