I need to make an anchor on my website and at the moment I have the following script :
<script>
$(document).ready(function() {
window.location.href='#foo';
});
</script>
It directs the page to the desired element, but by clicking the page it all goes down to where I want it with the tag:
<a href="#" id="foo"></a>
On this page I have links to photo galleries. I click, I'm redirected to the galleries normally and everything works as it should. But on the gallery page I have a back button that, when clicking, should go back to the previous page:
echo "<a href=\"about.php\" id=\"foo\" class=\"back\"><img src=\"images/left.png\"/> Voltar</a><br />";
It turns out that this way the anchor is not maintained. When I click back, the previous page is displayed, however, on top of it, not the anchor I was before entering the gallery.
How can I make the anchor hold, and when I click back, return to the same position as the page I was in?