Skip to content

Instantly share code, notes, and snippets.

@puneetkay
Created December 13, 2013 10:43
Show Gist options
  • Save puneetkay/7942579 to your computer and use it in GitHub Desktop.
Save puneetkay/7942579 to your computer and use it in GitHub Desktop.
Global JS function to get Query String
window.GetQueryString = function(q) {
return (function(a) {
if (a == "") return {};
var b = {};
for (var i = 0; i < a.length; ++i) {
var p = a[i].split('=');
if (p.length != 2) continue;
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
})(q.split("&"));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment