Posted By

stevegrunwell on 03/27/11


Tagged

javascript textmate


Versions (?)

Parse a HTTP GET query string with Javascript


 / Published in: JavaScript
 

  1. /* Parse GET parameters (based on http://www.netlobo.com/url_query_string_javascript.html) */
  2. function parseHttpGet(key){
  3. key = key.replace(/[[]/,"\[").replace(/[]]/,"\]");
  4. var regexS = "[\?&]"+key+"=([^&#]*)";
  5. var regex = new RegExp( regexS );
  6. var results = regex.exec(window.location.href);
  7. return ( results != null ? results[1] : false );
  8. }

Report this snippet  

You need to login to post a comment.