history.pushState() change query values

后端 未结 3 1994
一个人的身影
一个人的身影 2020-12-10 15:01

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&

3条回答
  •  不知归路
    2020-12-10 15:55

    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:

    history.pushState({value: 1, value2: 2}, "Title", 'page.php');
    history.pushState({value: 1, value2: 'new value'}, "Title");
    

提交回复
热议问题