JS changing URL, refresh page

location.reload();

window.location.href = u.toString();

to generate URL you can use url.js library