Skip to content

Instantly share code, notes, and snippets.

@bchapuis
Last active July 10, 2021 13:37
Show Gist options
  • Save bchapuis/5575504 to your computer and use it in GitHub Desktop.
Save bchapuis/5575504 to your computer and use it in GitHub Desktop.
Retrieve the value of a GET parameter using javascript
function decodeUrlParameter(str) {
return decodeURIComponent((str+'').replace(/\+/g, '%20'));
}
function getUrlParameter(name) {
return decodeUrlParameter(decodeURI(
(RegExp(name + '=' + '(.*?)(&|$)').exec(location.search)||[,null])[1]
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment