append to url and refresh page

后端 未结 11 2239
终归单人心
终归单人心 2020-12-07 14:07

I am looking to write a piece of javascript that will append a parameter to the current url and then refresh the page - how can I do this?

11条回答
  •  猫巷女王i
    2020-12-07 15:10

    this should work (not tested!)

    var url = window.location.href;    
    if (url.indexOf('?') > -1){
       url += '¶m=1'
    }else{
       url += '?param=1'
    }
    window.location.href = url;
    

提交回复
热议问题