How can I just change the get parameter without redirecting?
parent.location.search = "?after=20";
// ok that changes, but also redirect to the new page
Any solution? Or answer is no, if its no, please write big no.
How can I just change the get parameter without redirecting?
parent.location.search = "?after=20";
// ok that changes, but also redirect to the new page
Any solution? Or answer is no, if its no, please write big no.
Uh, no - if you change the URL parameter, your browser will load the new page.
You cannot alter the querystring (ie. the part that stars with the ?) without reloading the page from the server. You can however use page anchors like http://www.example.com/page.html#anchorname to affect the url without reloading a page from the server.
You can come close with the anchor portion of the URL which is accessible by the hash
property of the location
object
parent.location.hash = "whatever value you want";
If your aim is to use the query string to store some state that can later be restored from a bookmark, you should use anchors instead.
However, if you must change the query string for some reason, actually there is a way. However, I don't endorse this. I'm just mentioning it for completeness.
When a server returns a 204 No Content
response, most browsers won't do anything -- i.e. won't even attempt to transition to another page or even wipe the current page. What you can do is to make the backend just emit a 204 response when a request is made to the same page that was just served, with a change in the query parameters.
You can't do this because it would be a security risk if you could.... If pages could change the value in the URL bar, it would be easy for page put up by a phisher to change that value to appear to be a page on your bank's website.