Ask Your Question
4

Is it possible to modify the window.location.hash without causing the webpage to scroll?

asked 2023-07-16 14:40:47 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-16 14:45:02 +0000

lalupa gravatar image

No, it is not possible to modify the window.location.hash without causing the webpage to scroll. When the hash is modified, the browser automatically tries to scroll the element whose ID matches the new hash value into view. However, there are some workarounds like using the HTML5 history API to modify the URL without changing the hash, or using JavaScript to temporarily disable scrolling while the hash is changed.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-16 14:40:47 +0000

Seen: 13 times

Last updated: Jul 16 '23