How to add parameters to a URL that already contains other parameters and maybe an anchor

后端 未结 9 781
逝去的感伤
逝去的感伤 2020-12-05 19:36

I\'m wondering how I can add a new parameter to an existing url. The problem is: the url may also contain an anchor.

For example:

http://www.example         


        
9条回答
  •  情书的邮戳
    2020-12-05 20:08

    I always use this code, and its working fine ...

    var currenturl=location.href;
    var url = location.href+"?ts="+true;
    window.location.replace(url,"_self");
    

提交回复
热议问题