I have a need to rewrite the URL in a title bar (to make a nice, shortened URL appear there instead of a messy Joomla redirect.) I now know how this can be done (works with most modern browsers that recognize HTML5). For instance:

window.history.replaceState("", "", "/new-url.htm");

See also this link.