title: How to get route parameter in JavaScript?
body: <p>I have a ASP.NET website that is URL-Rewriting enabled. I know how to get route parameters using C#:</p>
  
  <pre><code>Page.RouteData.Values["id"] as string;
  </code></pre>
  
  <p>But I don't know how to get it from javascript? Following is my rewritten link format:</p>
  
  <blockquote>
    <p><a href="http://www.domain.com/topic/" rel="noreferrer">http://www.domain.com/topic/</a>{id}/{title}</p>
  </blockquote>
  
  <p>I want to get this {id} field using JavaScript. Please help!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have this code that gets request parameter.</p>
  
  <pre><code>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, " "));
  }
  </code></pre>
  
  <p>How can this be modified to get route parameter?</p>