title: How to get query string parameter from SEO-friendly URL?
body: <p>I switched from using normal URL parameters to SEO-friendly URLs. For example, I have gone from this...</p>
  
  <pre><code>http://www.example.net/mypage.aspx?id=1
  </code></pre>
  
  <p>... to this:</p>
  
  <pre><code>http://www.example.net/mypage/1
  </code></pre>
  
  <p>Using JavaScript or jQuery, what would be the best way to get the id variable of 1?</p>
  
  <p>I currently use a function like this:</p>
  
  <pre><code>// get the values from the query string.
  function GetQueryStringParams(sParam) {
  var sPageURL = window.location.search.substring(1);
  
  var sURLVariables = sPageURL.split('&amp;');
  
  for (var i = 0; i &lt; sURLVariables.length; i++) {
      var sParameterName = sURLVariables[i].split('=');
      if (sParameterName[0] == sParam) {
          return sParameterName[1];
      }
  }
  </code></pre>
  
  <p>Is there a better way or am I stuck splitting the URL via the <code>/?</code>? And how would you handle multiple parameters?</p>
  
  <p><a href="http://www.example.net/mypage/1/2/3/4/5" rel="nofollow noreferrer">http://www.example.net/mypage/1/2/3/4/5</a></p>