Last active
December 18, 2015 10:39
-
-
Save ferronrsmith/5770260 to your computer and use it in GitHub Desktop.
simple JavaScript function to retrieve variables from the url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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