set url variable without going to a new page code example
Example 1: javascript change url
history.pushState({}, null, newUrl);
Example 2: 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);
}