我正在使用Ajax和hash进行导航.
有没有办法检查是否window.location.hash改变了这样?
http://example.com/blah #123到http://example.com/blah #456
如果我在文档加载时检查它,它可以工作.
但是如果我有基于#hash的导航,那么当我按下浏览器上的后退按钮时它就不起作用了(所以我从#456跳到了#123).
它显示在地址框内,但我无法用JavaScript捕获它.
javascript ajax javascript-events fragment-identifier hashchange
我有这样的URL:http://example.com#something如何删除#something,而不会导致页面刷新?
我尝试了以下解决方案:
window.location.hash = '';
Run Code Online (Sandbox Code Playgroud)
但是,这不会#从URL中删除哈希符号.