Home JAVASCRIPT Get URL Parameters (QueryStrings) using Javascript
function getQueryStringValue(key, default_)
  if (default_==null) default_=””;
  key = key.replace(/[\[]/,”\\\[“).replace(/[\]]/,”\\\]”);
  var regex = new RegExp(“[\\?&]”+key+”=([^&#]*)”);
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
    return qs[1];
The getQueryStringValue function is simple to use. Let’s say you have the following URL:
and you want to get the “YourName” querystring’s value:
var YourName_Value = getQueryStringValue(‘YourName’);
alert(YourName_Value); // Result = “TME”

You may also like

Leave a Comment