Skip to content

Instantly share code, notes, and snippets.

@EricYue2012
Created November 14, 2013 04:26
Show Gist options
  • Save EricYue2012/7461348 to your computer and use it in GitHub Desktop.
Save EricYue2012/7461348 to your computer and use it in GitHub Desktop.
Get URL query string value
function getParameterByName(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