title: How can I get query string parameter in Javascript or jQuery?
body: <p>I have a link like this:</p>
  
  <pre><code>http://localhost:8162/UI/Link2.aspx?txt_temp=123abc
  </code></pre>
  
  <p>I want to get the value <code>123abc</code> . I have followed this <a href="https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144">How can I get query string values in JavaScript?</a> and 
  <a href="https://stackoverflow.com/questions/4656843/jquery-get-querystring-from-url">jquery get querystring from URL</a></p>
  
  <pre><code>$(document).ready(function () {
      function getUrlVars() {
          var vars = [], hash;
          var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
          for (var i = 0; i &lt; hashes.length; i++) {
              hash = hashes[i].split('=');
              vars.push(hash[0]);
              vars[hash[0]] = hash[1];
          }
          return vars;
      }
      function getParameterByName(name) {
          name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
          var regex = new RegExp("[\\?&amp;]" + name + "=([^&amp;#]*)"),
          results = regex.exec(location.search);
          return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
      }
      onload = function () {
          alert(getParameterByName('txt_temp'));
          alert(getUrlVars()["txt_temp"]);
      }  
  });
  </code></pre>
  
  <p>But it does not work.</p>