I have URL like: http://example.com#something, how do I remove #something, without causing the page to refresh?
I attempted the following
Here is another solution to change the location using href and clear the hash without scrolling.
The magic solution is explained here. Specs here.
const hash = window.location.hash;
history.scrollRestoration = 'manual';
window.location.href = hash;
history.pushState('', document.title, window.location.pathname);
NOTE: The proposed API is now part of WhatWG HTML Living Standard