Update to Davids answer to even detect browsers that do not support pushstate:
if (history.pushState) {
window.history.pushState(stateObj, "title", "url");
} else {
window.history.replaceState(stateObj, "title**", 'url');
// ** It seems that current browsers other than Safari don't support pushState
// title attribute. We can achieve the same thing by setting it in JS.
document.title = "Title";
}
stateObj
The state object is a JavaScript object which is associated with the history entry passed to the replaceState method. The state object can be null.
title
Most browsers currently ignore this parameter, although they may use it in the future. Passing the empty string here should be safe against future changes to the method. Alternatively, you could pass a short title for the state.
url Optional
The URL of the history entry. The new URL must be of the same origin as the current URL; otherwise replaceState throws an exception.