My navigation menu is generated in a single PHP file and included in each page. Some of the links are simply anchors on the homepage. When the user is on another page, these links should take them to the home page and then to the appropriate anchor. However, if the user is already on the home page, it would be nice if the page didn't have to reload.
This will reload no matter what:
<a href="/home#anchor">link</a>
This won't reload if you're already on the home page, but doesn't work from other pages:
<a href="#anchor">link</a>
Is there a way to achieve the best of both worlds without using JavaScript?