Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.