The history.back()
function is supposed to take me back one step in the history created using HTML5 history API. The following code works as expected in Firefox but does not in Chrome:
<html>
<script type="text/javascript">
history.replaceState({path: '/home'}, '', '?page=home');
history.pushState({path: '/second'}, '', '?page=second');
console.log(history.state.path); // says "/second"
history.back();
console.log(history.state.path); // says "/second" but should say "/home"
</script>
</html>
In Chrome, it prints /second
both times, whereas after going back it should print /home
. Am I missing something?