Skip to content

Instantly share code, notes, and snippets.

@varemenos
Last active December 14, 2015 22:49
Show Gist options
  • Save varemenos/5161407 to your computer and use it in GitHub Desktop.
Save varemenos/5161407 to your computer and use it in GitHub Desktop.
JavaScript - Parse url parameters
var params = {};
var queryString = location.search.substring(1); // For # params use location.hash
var regex = /([^&=]+)=([^&]*)/g;
var m;
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment