Skip to content

Instantly share code, notes, and snippets.

@bchapuis
Last active July 10, 2021 13:37
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