Skip to content

Instantly share code, notes, and snippets.

@MrJoshFisher
Created May 17, 2021 09:46
Show Gist options
  • Save MrJoshFisher/d99236a608c3576106b1dbcd0419c30a to your computer and use it in GitHub Desktop.
Save MrJoshFisher/d99236a608c3576106b1dbcd0419c30a to your computer and use it in GitHub Desktop.
[get URL parameter using jQuery or plain JavaScript]
/* https://stackoverflow.com/questions/19491336/how-to-get-url-parameter-using-jquery-or-plain-javascript */
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = 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 typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment