Return to Snippet

Revision: 43600
at March 27, 2011 09:55 by stevegrunwell


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

Revision: 43599
at March 27, 2011 09:53 by stevegrunwell


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

Initial URL


Initial Description


Initial Title
Parse a HTTP GET query string with Javascript

Initial Tags
javascript, textmate

Initial Language
JavaScript