Is it possible to add a hash to the URL without scrolling the page using JavaScript?
- I navigate to the page
- I scroll down
- I click on a link that adds a hash (for example: http://www.example.com/#test)
- The page should not scroll back to the top.
What is the best way to achieve this?
Note: I am exploring ways to prevent the default behavior of scrolling when adding a hash, even if there is an element with the specific ID like "test". The use of return false; seems to be effective in supporting users without JavaScript and avoiding conflicts with IDs in the HTML except for simple numbers. Many answers have been provided, all helpful but no groundbreaking solutions to alter the default functionality. Nonetheless, they are appreciated. Thank you for your responses.