Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Last active February 12, 2016 05:27
Show Gist options
  • Save steveosoule/4073787 to your computer and use it in GitHub Desktop.
Save steveosoule/4073787 to your computer and use it in GitHub Desktop.
JavaScript Query String Parameter Helpers
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