Created
August 8, 2013 21:57
-
-
Save JeffJacobson/6189166 to your computer and use it in GitHub Desktop.
Gets a query string parameter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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