Skip to content

Instantly share code, notes, and snippets.

@geraldyeo
Created January 12, 2015 03:23
Show Gist options
  • Select an option

  • Save geraldyeo/efebf61232696919d35f to your computer and use it in GitHub Desktop.

Select an option

Save geraldyeo/efebf61232696919d35f to your computer and use it in GitHub Desktop.
Parse a query string into an object
//http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
var queryString = {};
location.href.replace(/([^?=&]+)(=([^&]*))?/g, function($0, $1, $2, $3) {
queryString[$1] = $3;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment