Skip to content

Instantly share code, notes, and snippets.

@radius
Created July 30, 2012 16:08
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 radius/3208063 to your computer and use it in GitHub Desktop.
Save radius/3208063 to your computer and use it in GitHub Desktop.
Get URL Query String Parameters with Javascript
var urlParams = (function () {
var _params={},
e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1);
while (e = r.exec(q)) {
_params[d(e[1])] = d(e[2]);
}
return _params
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment