Skip to content

Instantly share code, notes, and snippets.

@joshbeckman
Created September 26, 2013 17:05
Show Gist options
  • Save joshbeckman/6717179 to your computer and use it in GitHub Desktop.
Save joshbeckman/6717179 to your computer and use it in GitHub Desktop.
Simple function to get all url query parameters for current page
var params = {};
if (location.search) {
var parts = location.search.substring(1).split('&');
for (var i = 0; i < parts.length; i++) {
var nv = parts[i].split('=');
if (!nv[0]) continue;
params[nv[0]] = nv[1] || true;
}
}
// Now you can get the parameters you want like so:
var abc = params.abc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment