这个问题之前已经被问过,但我需要一个更多的跨浏览器*选项,而不是 git-hub 选项。
有什么需要改变的吗:
http://stackoverflow.com/test#hey
至:
http://stackoverflow.com/test
使用 javascript 而不重新加载页面? (再次点击服务器)
*“更多跨浏览器”是指 IE7+ FF3.5+,而不是 IE6 等
最佳答案
您可以使用<a href="https://developer.mozilla.org/en/DOM/window.history" rel="noreferrer noopener nofollow">history.pushState()</a>
为此。
这将删除哈希值:
history.replaceState( {}, '', location.href.split('#')[0] );
为了跨浏览器兼容性,您可以使用 history.js作为填充。
关于JavaScript 'redirect' 没有页面重新加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5729287/