testCoder
testCoder

Reputation: 7385

how to clear browser hash history in javascript

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?

Upvotes: 0

Views: 9052

Answers (2)

David Pärsson
David Pärsson

Reputation: 6257

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.

Upvotes: 1

Ayyappan Sekar
Ayyappan Sekar

Reputation: 11475

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 :)

Upvotes: 0

Related Questions