Skip to content

Instantly share code, notes, and snippets.

@jordanthomas
Last active September 28, 2015 22:48
Show Gist options
  • Save jordanthomas/1507745 to your computer and use it in GitHub Desktop.
Save jordanthomas/1507745 to your computer and use it in GitHub Desktop.
Automagic querystring params in js
window.params = (function() {
var obj = {},
pattern = new RegExp( '([^?=&]+)=?([^&]*)?','g' );
while ( match = pattern.exec( window.location.search ) ) {
obj[match[1]] = match[2] ? match[2] : true;
}
return obj;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment