gpt4 book ai didi

javascript - 在不引起重定向的情况下向 URL 添加片段?

转载 作者:IT王子 更新时间:2023-10-29 02:49:45 26 4
gpt4 key购买 nike

有没有办法在不重定向的情况下将哈希 # 添加到我的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com