I have a button as an image...

I need some javascript in an onclick where when click it will navigate to a local anchor. For example:

How can I do this?
Update: This is the code I'm using:
onclick="document.location=#goToPage';return false;"
it looks the onClick
should be:
onclick="document.location+='#goToPage';return false;"
The solution presented in the accepted answer has the important issue that it can only be used 1 time. Each consecutive click appends #goToPage
to location and the window won't navigate to the anchor.
A solution is to remove the anchor part before appending a new anchor:
function goToAnchor(anchor) { var loc = document.location.toString().split('#')[0]; document.location = loc + '#' + anchor; return false; }
Usage example:
Anchor
Note that the anchor needs to be enclosed in quotes, without the hash prefix.
Wrap it in an anchor tag. You don't need to use JS.