I am working on my WordPress website and when the user clicks on the <a href="#id">
tag, the #id is not showing in the URL and because of that, when the user clicks on the back button, it is taking me to the back not on the top of the page.
I want that, when the user click on the <a href="#id">
tag and it moves to that id but when the user clicks on the back button, it should take me to the top of the page. Now, it is taking me to the back page.
Any help is much appreciated.
I am working on my WordPress website and when the user clicks on the <a href="#id">
tag, the #id is not showing in the URL and because of that, when the user clicks on the back button, it is taking me to the back not on the top of the page.
I want that, when the user click on the <a href="#id">
tag and it moves to that id but when the user clicks on the back button, it should take me to the top of the page. Now, it is taking me to the back page.
Any help is much appreciated.
Share Improve this question asked Nov 28, 2019 at 14:14 Rahul KumarRahul Kumar 2074 silver badges20 bronze badges 1- You need to give the top its own anchor then, because the url without any fragment it is not automatically associated to the top. Also before any other user interaction, update the url with the fragment you associate to the top, to allow the history go back to it. – Jesús Franco Commented Nov 29, 2019 at 2:38
1 Answer
Reset to default 1The solution is: Just add the page scroll id plugin.
After installing the plugin, Go to the Links behavior
section:
Check this option: Append the clicked link’s hash value (e.g. #id) to browser’s URL/address bar.
By doing this, id shows in the URL and when you click the back button after going to the id, the page will come to the own page.