Here is a function for getting the query string parameter values from a current window.

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];
}

Eg: var = gup('parameterName');

Source: http://www.netlobo.com/url_query_string_javascript.html

Advertisements