Skip to content

Instantly share code, notes, and snippets.

@takumakei
Created December 22, 2012 08:51
Show Gist options
  • Save takumakei/4358101 to your computer and use it in GitHub Desktop.
Save takumakei/4358101 to your computer and use it in GitHub Desktop.
parse query string in javascript
function queryString(name) {
var results = new RegExp(
'[\\?&]' +
name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]') +
'=([^&#]*)'
).exec(window.location.search);
if (null === results) return '';
return decodeURIComponent(results[1].replace(/\+/g, ' '));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment