Created
March 15, 2014 16:58
-
-
Save leegee/9570433 to your computer and use it in GitHub Desktop.
JS URI Params
This file contains hidden or 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
/** @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