Skip to content

Instantly share code, notes, and snippets.

@mudpuddle
Last active August 29, 2015 14:05
Show Gist options
  • Save mudpuddle/d7326d991484392d020d to your computer and use it in GitHub Desktop.
Save mudpuddle/d7326d991484392d020d to your computer and use it in GitHub Desktop.
Get url parameters by name using javascript.
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, " "));
}
@mudpuddle
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment