how to clear browser hash history in javascript

耗尽温柔 提交于 2020-01-06 07:57:05

问题


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/

but when i go to last #root/ in list i would like to clear previous navigation history

#root/folder -> #root/folder/subfolder

Is any ability to do that?


回答1:


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.




回答2:


there is a way in Javascript to navigate to a new page with leaving no history in the browser hash... just use window.location.replace("any URL");... see ur browser's page navigation buttons got disabled.. and also no 'Back' option will be available in right mouse click.. Hope this will help u :)



来源:https://stackoverflow.com/questions/13622460/how-to-clear-browser-hash-history-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!