Last active
February 12, 2016 05:27
-
-
Save steveosoule/4073787 to your computer and use it in GitHub Desktop.
JavaScript Query String Parameter Helpers
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
window.params = function(){ | |
var params = {}, | |
href = window.location.href, | |
param_array = ( href.indexOf('?') > -1 ) ? window.location.href.split('?')[1].split('&') : []; | |
for(var i in param_array){ | |
x = param_array[i].split('='); | |
params[x[0]] = x[1]; | |
} | |
return params; | |
}(); | |
for (var key in window.params) { | |
var value = window.params[key]; | |
console.log(key + ': ' + value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment