Skip to content

Instantly share code, notes, and snippets.

@bhrott
Created September 18, 2015 18:52
Show Gist options
  • Save bhrott/b990550e03a5fa7c2d89 to your computer and use it in GitHub Desktop.
Save bhrott/b990550e03a5fa7c2d89 to your computer and use it in GitHub Desktop.
Get value from url querystring by name
function getQueryStringValueByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment