Skip to content

Instantly share code, notes, and snippets.

@matheuscas
Last active August 16, 2016 17:58
Show Gist options
  • Save matheuscas/f45cf820c5dd77f9c7db9294733851ff to your computer and use it in GitHub Desktop.
Save matheuscas/f45cf820c5dd77f9c7db9294733851ff to your computer and use it in GitHub Desktop.
Get param from url using its name
function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment