.Js history support

I am changing the state of browser history using history.js. Let's say I use this code:

History.pushState({someState:2}, null, "?someState=2"); 

binding to the statechange event, it is easy to change the page based on the contents of History.state.data, but History.state is not set when the page loads initially (when someone saves the URL in the bookmark for an example). Therefore, I assume that in this case I should use the query string (part of the site someState = 2). When using a backup for "HTML4 browsers", I think I will have to use the hash of the URL. My question is: does history.js make an easy way to do all this, or is it really only for history, not bookmarks?

I hope the question is clear.

+4
source share
1 answer

Have you tried History.getState() ?

0
source

Source: https://habr.com/ru/post/1389816/


All Articles