update parameters in URL with history.pushState()

前端 未结 2 1896
离开以前
离开以前 2021-02-05 05:02

I am using history.pushState to append few params to current page URL after making an AJAX call on my page. Now on same page based on user action, I want to update the page URL

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 05:48

    I think what you need is remove window.location.href and leave '?' +.

    var pageUrl = '?' + queryString;
    window.history.pushState('', '', pageUrl);
    

提交回复
热议问题