Thursday, July 5, 2012

Jquery Method to get querystring values

Jquery Method to get querystring values

Reference link :http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
I like the way of stack overflow user as they help the users :

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