Why does the following code make the scroll jump to the top of the page?
window.location.hash = ''
Is there a way to empty it without jumping to the top of the page?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
window.location.hashkeeps track of the current anchor position on the page. When you set it to be an anchor, the page will automatically go to that anchor. When you remove it, the page will go to ‘blank’ which is the top of the page!To get around this do the following: