Skip to content

Instantly share code, notes, and snippets.

@leegee
Created March 15, 2014 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leegee/9570433 to your computer and use it in GitHub Desktop.
Save leegee/9570433 to your computer and use it in GitHub Desktop.
JS URI Params
/** @return A hash keyed by URI param name, values always being arrays */
function paramsFromURI(){
var p = {};
var a = document.location.search.substring(1).split(/[;&]+/);
for (var i=0; i<a.length; i++){
var kv = a[i].split(/=/);
p[kv[0]] = p[kv[0]] || [];
p[kv[0]].push( decodeURIComponent( kv[1] ) );
}
return p;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment