title: Edit URL before redirect
body: <p>Here  I am stuck with a scenario where I want to edit <code>href</code> of <code>anchor tag</code> before redirect. My scenario is if <code>href</code> attribute of <code>anchor tag</code> do not contain <code>QueryString</code> then append previous page query string to <code>href</code> means, suppose my current page url is <code>xyz?x=2&amp;y=4</code>
  <strong>Current href</strong></p>
  
  <pre><code>href="local/services"
  </code></pre>
  
  <p><strong>After Edit</strong></p>
  
  <pre><code>href="local/services?x=2&amp;y=4"
  </code></pre>
  
  <p>I tried.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;a href="http://localhost/services" onclick="appendString(this)"&gt;test link &lt;/a&gt; 
  </code></pre>
  
  <p>JavaScript</p>
  
  <pre><code>function appendString(obj) {
     var url = obj.getAttribute('href');
      if (url.indexOf('?') != -1)
        obj.setAttribute('href') = url + window.location.search;
      }
  </code></pre>
  
  <p>also tried</p>
  
  <pre><code>function appendString(obj) {
      var url = obj.getAttribute('href');
       if (url.indexOf('?') != -1)
           window.location.href =  url + window.location.search;
        }
  </code></pre>
  
  <p>but no success.
  Please suggest a solution.
  Thanks.</p>