Skip to content

Instantly share code, notes, and snippets.

@ao
Created November 24, 2014 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ao/b9c6a03782cc17b36554 to your computer and use it in GitHub Desktop.
Save ao/b9c6a03782cc17b36554 to your computer and use it in GitHub Desktop.
Javascript $_GET variables
function $_GET(q, s) {
s = s ? s : window.location.search;
var re = new RegExp('&' + q + '(?:=([^&]*))?(?=&|$)', 'i');
return (s = s.replace(/^\?/, '&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment