Skip to content

Instantly share code, notes, and snippets.

@juliarose
Created April 4, 2019 13:24
Show Gist options
  • Save juliarose/98a54bc5ee0ea45f61493247532a2111 to your computer and use it in GitHub Desktop.
Save juliarose/98a54bc5ee0ea45f61493247532a2111 to your computer and use it in GitHub Desktop.
Simple method for getting the value of a URL parameter
/**
* Get a URL parameter
* @param {String} name - Name of parameter
* @returns {(String|null)} The value of parameter, if found
*/
function getUrlParam(name) {
return new URL(location.href).searchParams.get(name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment