History.pushstate and history.replacestate can change the URL without refreshing the current page, but this will not get the content of the new page that gets through Ajax.
Although various HTML5 documents say that the Window.onpopstate event can intercept pushstate messages, in the actual test, Onpopstate has no effect at all and cannot intercept pushstate messages.
After Google, we found the code to get the Pushstate event correctly.
https://stackoverflow.com/a/25673911
//ADD this:var_WR =function(type) {varOrig =History[type]; return function() { varRV = orig.apply ( This, arguments); varE =NewEvent (type); E.arguments=arguments; Window.dispatchevent (e); returnRV; };}; History.pushstate= _WR (' pushstate '); History.replacestate= _WR (' replacestate ');//Use it like this :Window.addeventlistener (' Pushstate ',function(e) {Console.warn (' They did IT again! ');}); Window.addeventlistener (' Replacestate ',function(e) {Console.warn (' They did IT again! ');});
This code overwrites the original function in the history and then activates an event yourself
This will solve the problem that pushstate cannot activate the event.
Also remember that it is best to put this code before the document is loaded to execute
Intercepting Pushstate and replacestate events via JS