Skip to content

Instantly share code, notes, and snippets.

@nicholasstephan
Last active October 10, 2015 16:18
JS: url params
function getQueryString() {
var e,
p = {}, // returned params
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.hash.substring(1);
while (e = r.exec(q))
p[d(e[1])] = d(e[2]);
return p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment