gib65
02-26-2015, 04:57 PM
I need a way to remove parameters from the URL without refreshing the page. The only way I know of to change the URL is by saying:
window.location.href = ...
But this refreshes the page.
I also tried this:
window.history.replaceState({}, "", window.location.href.substring(0, position_of_parameter_to_remove));
but this also seems to refresh the page.
The reason I need to remove the parameter from the URL is as follows: I have two buttons on the page. One of them adds the parameter to the URL and reloads the page with it. When the page reloads, I use that parameter. The second button also reloads the page, but in this case, I want the parameter not to be there so that it doesn't get used when the page reloads. However, I have no control over this button (it's in a special "captivate" object that I have no access to). So I cannot tell it to reload the page with a URL that doesn't have the parameter. It just reloads the page "as is". So I'm trying to remove the parameter as soon as it gets retrieved and used. That way, the parameter will only exist in the URL when the first button is clicked and the page reloads.
But I still don't know how to do that without doing another page reload. Can anyone help me?
window.location.href = ...
But this refreshes the page.
I also tried this:
window.history.replaceState({}, "", window.location.href.substring(0, position_of_parameter_to_remove));
but this also seems to refresh the page.
The reason I need to remove the parameter from the URL is as follows: I have two buttons on the page. One of them adds the parameter to the URL and reloads the page with it. When the page reloads, I use that parameter. The second button also reloads the page, but in this case, I want the parameter not to be there so that it doesn't get used when the page reloads. However, I have no control over this button (it's in a special "captivate" object that I have no access to). So I cannot tell it to reload the page with a URL that doesn't have the parameter. It just reloads the page "as is". So I'm trying to remove the parameter as soon as it gets retrieved and used. That way, the parameter will only exist in the URL when the first button is clicked and the page reloads.
But I still don't know how to do that without doing another page reload. Can anyone help me?