Return to Snippet

Revision: 5102
at February 11, 2008 17:45 by iTony


Initial Code
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

Initial URL
http://www.netlobo.com/url_query_string_javascript.html

Initial Description
This makes it easy to retrieve certain value from a url with different values appended to it.

Initial Title
retrieve values from a url

Initial Tags
regex, url, javascript

Initial Language
JavaScript