You can save state by changing the window.location.hash property. A hash is the only part of the URL that you can change rather than force a reload of the URL.
window.location.hash = 'some-id'; translates to your URL, which looks like this: index.html#some-id .
Then you can get the hash when the page loads, and set the user interface to the correct state:
if (window.location.hash == 'some-id') { //setup UI for `some-id` identifier }
source share