Skip to content

Instantly share code, notes, and snippets.

@Granze
Created March 25, 2012 22:24
Show Gist options
  • Select an option

  • Save Granze/2200398 to your computer and use it in GitHub Desktop.

Select an option

Save Granze/2200398 to your computer and use it in GitHub Desktop.
Get URL variables (regex)
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment