向URL添加片段而不会导致重定向? [英] Add a fragment to the URL without causing a redirect?
本文介绍了向URL添加片段而不会导致重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种方法可以在不重定向的情况下将hash#添加到我的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.
您的评论...
我真正需要的只是添加散列......像这样:<$ c $
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.hash ='#'; 试试这个......
Try this...
window.location = '#';
另外,不要忘记 window.location.replace()
方法。
这篇关于向URL添加片段而不会导致重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文