向 URL 添加片段而不导致重定向? [英] Add a fragment to the URL without causing a redirect?
本文介绍了向 URL 添加片段而不导致重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在不重定向的情况下将哈希 # 添加到我的 URL 中?
Is there is a way how to add hash # to my URL without redirect?
推荐答案
window.location.hash = 'something';
这只是普通的 JavaScript.
That is just plain JavaScript.
您的评论...
我真正需要的是只添加哈希......像这样:window.location.hash = '#';
但这样没有添加任何东西.
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()
方法.
Also, don't forget about the window.location.replace()
method.
这篇关于向 URL 添加片段而不导致重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文