Skip to content

Instantly share code, notes, and snippets.

@ferronrsmith
Last active December 18, 2015 10:39
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 ferronrsmith/5770260 to your computer and use it in GitHub Desktop.
Save ferronrsmith/5770260 to your computer and use it in GitHub Desktop.
simple JavaScript function to retrieve variables from the url
var getUrlVars = function () {
var vars = [], hash, $href, hashes, i;
$href = window.location.href;
hashes = $href.slice($href.indexOf('?') + 1).split('&');
for (i = 0; i < hashes.length; i += 1) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment