我有这样的URL:http://example.com#something如何删除#something,而不会导致页面刷新?
我尝试了以下解决方案:
window.location.hash = '';
Run Code Online (Sandbox Code Playgroud)
但是,这不会#从URL中删除哈希符号.
页面网址是http://example.com/dashboard#/catalog。Cookie过期后,我会执行
res.redirect('/login')
Run Code Online (Sandbox Code Playgroud)
浏览器中的结果网址为http://example.com/login#/catalog。
我如何在没有哈希部分的情况下重定向,即使网址成为 http://example.com/login
谢谢你的帮助!!
我想从URL中删除哈希以及后面的任何内容.例如,我可能有:
http://example.com/#question_1
Run Code Online (Sandbox Code Playgroud)
...滑到问题没有.1显示错误消息.当用户的输入然后通过验证时,我需要#question_1从当前位置删除.
我已经尝试了所有这些,但它们都没有为我工作:
document.location.href.replace(location.hash, "");window.location.hash.split('#')[0];window.location.hash.substr(0, window.location.hash.indexOf('#'));注意:我不只是想获取URL - 我想从地址栏中删除它.