Skip to content

Instantly share code, notes, and snippets.

@peacefulseeker
Last active January 23, 2018 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peacefulseeker/73fcb6878613345b517f1a22f1a19a15 to your computer and use it in GitHub Desktop.
Save peacefulseeker/73fcb6878613345b517f1a22f1a19a15 to your computer and use it in GitHub Desktop.
getUrlParameter
var getUrlParameter = 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];
}
}
};
if (getUrlParameter('f')) {
var param = getUrlParameter('param');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment