Last active
May 21, 2016 14:11
-
-
Save cian6390/f99463297b48cee57b15556867a813fc to your computer and use it in GitHub Desktop.
JavaScript get url parameter with decode
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
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