Skip to content

Instantly share code, notes, and snippets.

@aegiz
Last active April 19, 2016 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aegiz/04cd8f3a756082a479c784b46cfc7af4 to your computer and use it in GitHub Desktop.
Save aegiz/04cd8f3a756082a479c784b46cfc7af4 to your computer and use it in GitHub Desktop.
Get query params from url
var getQueryParams = function(param){
param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+param+"=([^&#]*)",
regex = new RegExp( regexS ),
results = regex.exec( window.location.href);
return results === null ? false : decodeURIComponent(results[1].replace(/\+/g, " "));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment