gpt4 book ai didi

javascript - # 对于window.location.pathname

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

我正在尝试重定向到相对网址,如下所示

setTimeout(window.location.pathname = '/help/fusion/index.php#3', 500);

但是#在传递给window.location.pathname时似乎会引起问题。错误是

'The requested URL /help/fusion/index.php#3 was not found on this server.'

但是浏览器实际显示的url是localhost/help/fusion/index.php%233#1。有人知道如何避免这种情况吗?

最佳答案

您可以使用 window.location 在 JavaScript 中进行重定向,并将函数传递给 setTimeOut 函数。试试这个:

setTimeout(function() { window.location = '/help/fusion/index.php#3'; }, 500);

关于javascript - # 对于window.location.pathname,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14571873/

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