Well you are always pushing the index state in your example. What you could do is something like this: Instead of History.pushState write:
var p = window.location.search.replace( "?", "" ); //this gets you the parameter
History.replaceState({id: p}, '', '?'+p);
However, History state is preserved on refresh and as such on refreshing the page the statechange event will not fire, since the state doesn't change.
So to go around this you would need something like this:
var historyFired = false;
function onHistory() {
//put code previously in your statechange hanlder here
historyFired = true;
}
History.Adapter.bind(window,'statechange',onHistory);
var p = window.location.search.replace( "?", "" ); //this gets you the parameter
History.replaceState({id: p}, '', '?'+p);
if (!historyFired) onHistory();
It's a bit of a hack, but it does what you want it to do;