javascript add url parameter without losing code example
Example 1: javascript change url without reload
window.history.pushState('', 'New Page Title', '/new-url.php');
Example 2: javascript change url
history.pushState({}, null, newUrl);
window.history.pushState('', 'New Page Title', '/new-url.php');
history.pushState({}, null, newUrl);