Javascript inline onclick goto local anchor

Viewed 40563

I have a button as an image...

<img src="button.png" />

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

<img src="button.png" onclick="navigateTo #page10" />

How can I do this?

Update: This is the code I'm using:

onclick="document.location=#goToPage';return false;"
4 Answers

Try using with / slash for root or /folder/, so it can be used many times.

onclick="document.location='/#goToPage';return false;" 

onclick="document.location='/folder/#goToPage';return false;" 
Related