I am trying to change a hashed URL (document.location.hash) with the replace method, but it doesn\'t work.
$(function(){ var anchor = document.location.hash; /
You may prefer the answer of this question.
The difference being that with history.replaceState() you don't scroll to the anchor, only replace it in the navigation bar. It's supported by all major browsers, source.
history.replaceState()
history.replaceState(undefined, undefined, "#hash_value")