Skip to content

Instantly share code, notes, and snippets.

@icuy
Created April 16, 2019 15:03
Show Gist options
  • Save icuy/941c67c81d86ced2212c54e3e9ce8668 to your computer and use it in GitHub Desktop.
Save icuy/941c67c81d86ced2212c54e3e9ce8668 to your computer and use it in GitHub Desktop.
获取url的参数
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];
}
}
};
var code = getUrlParameter('code');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment