gpt4 book ai didi

javascript - 这个 header : header links referral to a different url? 有什么问题

转载 作者:行者123 更新时间:2023-12-01 15:28:04 25 4
gpt4 key购买 nike

我正在开发一个带有多个#sections 的单页应用程序
我在我的导航中有我的链接的标题,每个链接都引用同一页面中的#anchor(部分)。
但是我还有两页,比如法律声明和隐私政策。
我的问题:在这两个有问题的页面中,引用 #sections 的 header.php 的链接不再起作用。
在 JavaScript 中是否有可能根据我们找到标题链接的页面不引用#sections 而是引用我的 index.php #section ?
我希望清楚!
非常感谢任何可以帮助我的人!

最佳答案

我不确定您想要的特定代码,但您可以执行以下操作:

if(window.location.pathname == "page1"){

}else if(window.location.pathname == "page2"){

}

关于javascript - 这个 header : header links referral to a different url? 有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63793384/

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