将链接的 href 动态更改为仅其哈希值
我的网站顶部有一个主菜单,它在每个页面上,它有一些指向 coda 滑块面板(featurepage#1、featurepage#2 等)的链接,当用户来自时,这些链接可以将用户直接带到该面板不同的页面。
当我实际在功能页面上时,链接不起作用,它们只更改哈希值,而不会跳转到相关内容。
据我所知,这是因为链接中包含整个 URL,而不是所需的 #1、#2 等。
所以我的问题(和希望)是有一种方法可以更改这些链接的 HREF页面,因此 featurepage#1 变为 #1,依此类推。
问题还在于它是动态的,我不知道任何时候需要多少个哈希值,所以我不能简单地替换它们。
有人有什么想法吗?谢谢!!!!
I have a main menu on top of my site, its on every page, it has some links to coda slider panels (featurepage#1, featurepage#2 etc) which work to take the user directly to that panel, when they are coming from a different page.
When Im actually on the FeaturePage, the links dont work, they only change the hash, without jumping to the relevant content.
As far as I can see, its because the links have the whole URL in them, rather than the needed #1, #2 etc.
So my question (and hope) is there a way of changing the HREF for those links just on that page, so featurepage#1 is turned into #1 and so on.
The problem as well its that its dynamic, I have no idea how many Hash values will be needed at any time, so I cant just simply replace them.
Would anyone have any ideas? Thanks!!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,这将删除 # 之前的所有内容(如果存在)。我认为这从后端完成会更好。那里一开始就没有页面名称。
Well, this will remove everything before the # if one exists. I would think though that this would be better done from the backend. Don't have the page name in there to begin with.