JavaScript - navigating to a named anchor

I have a named HTML anchor tag that works like a bookmark. This tag is defined as:

<a name="myLocation"></a>

I need to go to this link using JavaScript. How to navigate to a location on my HTML page using JavaScript?

Thank!

+3
source share
1 answer

Try:

window.location = window.location + "#myLocation";

Hope this helps.

+5
source

Source: https://habr.com/ru/post/1732756/


All Articles