Skip to content

Instantly share code, notes, and snippets.

@loickreitmann
Created December 6, 2010 22:13
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 loickreitmann/731078 to your computer and use it in GitHub Desktop.
Save loickreitmann/731078 to your computer and use it in GitHub Desktop.
JS function to grab a QS param
function getQuerystringParamByName(name) {
var regexS, regex, results;
regexS = "[\\?&]" + name + "=([^&#]*)";
regex = new RegExp(regexS);
results = regex.exec(location.href);
if (results === null) {
return null;
} else {
return (results[1] !== '') ? results[1] : null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment