Skip to content

Instantly share code, notes, and snippets.

@timsavery
Created May 25, 2012 01:35
Show Gist options
  • Save timsavery/2785281 to your computer and use it in GitHub Desktop.
Save timsavery/2785281 to your computer and use it in GitHub Desktop.
function getQuerystringParamByName(name) {
name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
var regexS = '[\\?&]' + name + '=([^&#]*)'
, regex = new RegExp(regexS)
, results = regex.exec(window.location.search);
if(!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