change url javascript code example

Example 1: javascript change url hash

window.location.hash = '#hash_value';

Example 2: js change url

window.location.href = "www.google.com";

Example 3: javascript change url without reload

window.history.pushState('', 'New Page Title', '/new-url.php');

Example 4: java script change url without reload

window.history.replaceState({}, '','/dashboard');

Example 5: javascript change url

history.pushState({}, null, newUrl);

Example 6: change url without reloading

function processAjaxData(response, urlPath){
     document.getElementById("content").innerHTML = response.html;
     document.title = response.pageTitle;
     window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath);
 }