jQuery/Javascript - reload current page with an appended querystring?

后端 未结 6 473
小鲜肉
小鲜肉 2021-02-03 18:40

I\'ve got a dropdown menu on my form, which when something is selected I need to reload the current page, but with an appended querystring.

How would I go about doing th

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-03 18:57

    If you go with the top rated answer, you may want to replace

    http://
    

    in the code with

    window.location.protocol
    

    so that it works for other protocols, like https or file. So

    window.location.href = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + params.join('&');
    

提交回复
热议问题