Skip to content

Instantly share code, notes, and snippets.

@JeffJacobson
Created August 8, 2013 21:57
Show Gist options
  • Save JeffJacobson/6189166 to your computer and use it in GitHub Desktop.
Save JeffJacobson/6189166 to your computer and use it in GitHub Desktop.
Gets a query string parameter.
/** Gets a query string parameter.
@returns {String|null} Returns the value of the query string parameter, or null if that parameter is not defined.
*/
function getQueryStringParameter(/** {String} */ key) {
var keyRe, match, output = null;
if (document.location.search.length) {
keyRe = new RegExp(key + "=([^\\&]+)", "i");
match = document.location.search.match(keyRe);
if (match) {
output = match[1];
console.log(key, output);
}
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment