Reputation: 31
I have a FAQ page i have created with many questions and answers in the form of
<div>
<h4 id="anchor-name">question</h4>
<p>answer</p>
</div>
This works as expected if i have a button or clickable link in the form of
<a href="#anchor-name">Click here to go to anchor</a>
which takes me directly to my question with that id (expected behaviour) The problem is when i try to access this from a URL from another tab by doing something like
https://my-app-url/#/FAQ/#anchor-name
it redirects me to my FAQ page but not to my question. Instead, it just loads the FAQ and stays on the top.
Some context:
https://my-app-url/#/FAQ/#anchor-name
is mandatory. Apparently if i just go with https://my-app-url/FAQ/#anchor-name
it never loads the page<div>
tags and the <h4>
tags by an <a>
tag but it didn't work. In those cases what i did was<div>
<a href="#anchor-name">
<h4 id="anchor-name">question</h4>
<p>answer</p>
</a>
</div>
What i wish to know and cannot seem to find it by doing research a lot is:
Upvotes: 1
Views: 526
Reputation: 31
For anyone who might be interested, I fixed this issue. The problem was fixed by replacing HashHistory with BrowserHistory. With HashHistory, the URL gets an # that interferes with anchors. By using BrowserHistory, that # is never there so the issue is gone. Hopes this helps.
Upvotes: 0
Reputation: 3613
You don't need that last /
right before the #anchor-tag
.
so the URL would be:
https://my-app-url/#/FAQ#anchor-name
Upvotes: 1