Skip to content

Instantly share code, notes, and snippets.

@mpjura
Created October 1, 2012 18:31
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 mpjura/3813560 to your computer and use it in GitHub Desktop.
Save mpjura/3813560 to your computer and use it in GitHub Desktop.
getParams
function getParams(key){
var url = window.location.href,
params = {}, i;
url = url.split('#')[0].split('?')[1];
if ( !url ) return undefined;
url = url && url.split('&');
while ( i = url.shift() ){
i = i.split('=');
params[ i[0] ] = i[1] || true;
}
return ( key ) ? params[key] || undefined : params;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment