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.
Since this is the accepted answer, and no longer true, refer to this duplicate question for up to date information.
Original answer follows:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With