gpt4 book ai didi

javascript - 当只有 url 哈希更改时,如何重新加载整个页面?

转载 作者:行者123 更新时间:2023-11-28 13:57:57 24 4
gpt4 key购买 nike

如果对 url 的唯一更改是哈希值,如何重新加载页面? location.href 无法按我的预期工作。

location.href= siteUrl + '#T_blockName';

除非我更改 siteUrl,否则不会刷新页面。怎么可能?

最佳答案

您需要使用location.hash。这检索哈希值。要更改它,您需要使用 anchor 或将 window.location 设置为位置加上所需的哈希值。

此外,当您应该使用 + 时,您却使用了 PHP 连接语法。

关于javascript - 当只有 url 哈希更改时,如何重新加载整个页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6943301/

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