I'm using the following code to change the URL of a page without reloading the whole page:
alert( window.location.href );
window.history.pushState( {} , 'foo', '/foo' );
alert( window.location.href );
Result:
First alert:
file:///C:/Users/name/Desktop/html/first.html
Second alert:
No Alert and no change in URL but I was expecting following:
file:///C:/Users/name/Desktop/html/foo
Where's the glitch? And how to change the browser URL without reloading the page?