I am using hash in order to avoid reloading the page (yeah, I know there's a new history API, but whatever...)
But now I want to change the hash without adding it to session History (i.e. don't want it in back button list), or add it removing the previous one. So what I don't want is having both the new one and old one in the list.
It seems I can use location.replace
:
location.replace( location.href.replace(/#.+/, '') + '#' + newHash );
On Firefox 29 it works well and, since I have changed only the hash, the page isn't reloaded.
But does it work like this on all browsers (IE, I'm looking at you)?
After testing (test page) with browserling and browserstack, it seems that
Specifically, my code works on
And, according to IETester, it works on IE 5.5 too.
Edit - The following code also works (test page), with same browser support:
location.replace('#' + newHash);