Skip to content

Instantly share code, notes, and snippets.

@xlbruce
Created February 24, 2016 21:20
Show Gist options
  • Save xlbruce/be3f2e924a4300a2f6b4 to your computer and use it in GitHub Desktop.
Save xlbruce/be3f2e924a4300a2f6b4 to your computer and use it in GitHub Desktop.
Gets a param in a query string (JavaScript)
function get(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment