Skip to content

Instantly share code, notes, and snippets.

@toruta39
Created July 14, 2012 02:03
Show Gist options
  • Save toruta39/3108797 to your computer and use it in GitHub Desktop.
Save toruta39/3108797 to your computer and use it in GitHub Desktop.
Get arguments in the query string
function getQueryStringArgs() {
var qs = (location.search.length > 0 ? location.search.substring(1) : "");
var args = {};
var items = qs.split("&");
var item = null,
name = null,
value = null;
for (var i = 0; i < items.length; i++) {
item = items[i].split("=");
name = decodeuricomponent(item[0]);
value = decodeuricomponent(item[1]);
args[name] = value;
}
return args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment