Reputation: 5896
I am looking for a way to alter the get query string of an html request using javascript (jquery included) without refreshing the page. This query string would be carried over when refresh. For instance, http://thissite.site/index.html?id=123
would be the original url, then an event happens and id changes to 235. When the page is refreshed, the refreshed link would be http://thissite.site/index.html?id=235.
Upvotes: 4
Views: 4344
Reputation: 2262
With HTML 5 you can use the the following pushState function
. More info found on How does pushState protect against potential content forgeries?.
I was looking for this as well and saw bandcamp using this for the navigation on http://bandcamp.com/discover
Upvotes: 0
Reputation: 92893
window.location.search = "?id=" + encodeURIComponent(new_value)
https://developer.mozilla.org/docs/DOM/window.location
https://developer.mozilla.org/docs/JavaScript/Reference/Global_Objects/encodeURIComponent
Upvotes: 5