Skip to content

Instantly share code, notes, and snippets.

@cian6390
Last active May 21, 2016 14:11
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 cian6390/f99463297b48cee57b15556867a813fc to your computer and use it in GitHub Desktop.
Save cian6390/f99463297b48cee57b15556867a813fc to your computer and use it in GitHub Desktop.
JavaScript get url parameter with decode
function getUrlVars() {
var url = decodeURIComponent(window.location.href);
var vars = {};
var hashes = url.split("?")[1];
var hash = hashes.split('&');
for (var i = 0; i < hash.length; i++) {
params = hash[i].split("=");
vars[params[0]] = params[1];
}
return vars;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment