有没有办法在不重定向的情况下将哈希 # 添加到我的 URL?
最佳答案
window.location.hash = 'something';
那只是普通的 JavaScript。
你的评论...
Hi, what I really need is to add only the hash... something like this:
window.location.hash = '#';
but in this way nothing is added.
试试这个...
window.location = '#';
此外,不要忘记 window.location.replace()
方法。
关于javascript - 在不引起重定向的情况下向 URL 添加片段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4282069/