If I have a link that is being changed with the function history.pushState({}, "", link);
where my link
is for example page.php?value=1&value2=2
Is there a way to just change the value2
with pushState()
function instead of changing the whole link?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
- jQuery add and remove delay
No, because the query string is part of the URL. If you don't truly need to pass those values for the purposes of the server, you can include them in the history's state object itself, and then you can change just the state object with
pushState()
. For example:You can use this useful function to change a query string parameter value:
If what you're trying to do is change the URL without adding an additional entry to the history object, you might try
replaceState
.