The concerning site-url is example.com/news/. The page that is loaded via this url contains some checkboxes and a button. I use an object filter with some keys like checkbox1, checkbox2, etc. and if the checkboxes are checked the keys get a true-value, if they are unchecked the keys get a false-value.
In the end, there is a var overwriteURL, which contains let's say the value "general-seniors-youth".
Now when the button is clicked, I want the script to load a page into a container and change the url to example.com/news/general-seniors-youth/ without loading a new site.
I achieve this by the following code:
if(overwriteURL !== "" ) {
history.pushState({ test: "test" }, null, "/news/" + overwriteURL + "/");
}
That works fine.
As the documentation of Mozilla (https://developer.mozilla.org/de/docs/Web/Guide/DOM/Manipulating_the_browser_history) says in English:
If I navigate to google.com (for example) after the script ran and then use the back-button of my browser, the URL-bar should actually contain the changed URL, so example.com/news/general-seniors-youth/. But it does contain the orginal URL before the pushState, so example.com/news/.
But when I don't navigate to google.com but use the back-button as often as I want and then the forward-button till it reaches the latest history-entry, then the rigth (changed) URLis displayed in the URL-bar.
Where's the mistake?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…