example code from https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_history/Example