title: How to alter URL to add a query with JQ?
body: <p>well I hope you can help me here, I'm quite a neophyte in JQ and I struggle to find how alter the URL of my page automatically.</p>
  
  <p>Here I explain :
  I got a function that search the URL for a specific query and does something according the value of the query. this one is done and works.
  I now need to make one that'll alter the URL while loading the concerned page, I cannot make a generic one since not every pages are supposed to have the query nor are every pages supposed to have the same value (and so not having the same answer from the previous function), how I do it that way because this value is meant to be changed.
  the idea is that the former function will be on a static bloc in every pages and will be just "sleeping" when the later has not alter the page. So the later just need to be put in only specific pages to alter the URL...</p>
  
  <p>I tinkered a bit with location.search and all but I usually and up with infinite redirect loop or having www.site.com/en/theUrl/undefined?[myquery] rather than www.site.com/en/theUrl?[myquery]</p>
  
  <p>Here is the searching part of the first function :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> function CheckUrlParams(){
    //Get the URL as String and search for queries 
    var sPageURL = location.search.substring(1);
    //Split the URL string into an array[String]
    var sURLVariables = sPageURL.split("&amp;");
    for (var i = 0; i &lt; sURLVariables.length; i++){
     //Sub-Split the URL array[String] into an array[String]
     var sParameterName = sURLVariables[i].split("=");
     if (sParameterName[0] == "WMV"){
      return sParameterName[1];
     }
    }
   }</code></pre>
  </div>
  </div>
  </p>
  
  <p>the query is supposed to be "?WMV=123456"</p>
  
  <p>I had thought  to something like : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>       //Let's say WMVID = 123456
         jQuery(window).ready(function AlterUrlParams (WMVID){
              jQuery(this).attr('href', this.href + '?WMV='+WMVID );
        location.search = this.href;
       });</code></pre>
  </div>
  </div>
  </p>
  
  <p>But I guess I don't really get the "How it works" about it</p>
  
  <p>Hope you guys can help me with this :)</p>