Return to Snippet

Revision: 12542
at March 18, 2009 14:46 by nelsnelson

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 "";
    return results[1];

Initial URL

Initial Description
Here is a small function [[lobo235]( "Javascript Tool-tips")] wrote that will parse the window.location.href value and return the value for the parameter you specify. It does this using javascript's built in regular expressions.

Initial Title
Javascript function to get URL query string parameters

Initial Tags
url, javascript

Initial Language