Skip to content

Retrieving Query String Values on JS

October 31, 2012

If for whatever reason you need to do JS scripting on the client side for obtaining any Query String you may place on your browser window.
You many think that you need to do fancy JQuery in order to process it, wrong, you don’t need to, as there is plain Javascript that can handle its values.Here is a very useful function in Javascript for retrieving Query String Values on the client side (without using JQuery).


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

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: