The window.location.pathname part isn't needed, a URL starting with "?" will change the parameters on the current page.