如何清除JavaScript中的浏览器哈希历史记录 [英] how to clear browser hash history in javascript
问题描述
我使用 hashchange 插件来模仿ajax导航,喜欢创建整个文件夹中的导航,例如:
I use hashchange plugin to imitate ajax navigation, i would like to create navigation throught folders, for example:
#root/->#root/folder->#root/folder/subfolder-> #root/
但是当我转到列表中的最后一个 #root/时,我想清除以前的导航历史记录
but when i go to last #root/ in list i would like to clear previous navigation history
#root/folder->#root/folder/subfolder
有能力做到这一点吗?
推荐答案
具有HTML5支持的现代浏览器支持通过window.history
进行的某些操作.根据Mozilla开发人员网络上的文档,唯一受支持的操作是: 添加和替换历史记录.
Modern browsers with HTML5 support supports some manipulation via window.history
. According to the docs at Mozilla Developer Network, the only supported actions are to add and replace history.
Removing browser history is thus not supported, but maybe history.replaceState()
can be used to suit your needs.
这篇关于如何清除JavaScript中的浏览器哈希历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!