Created
October 1, 2012 18:31
-
-
Save mpjura/3813560 to your computer and use it in GitHub Desktop.
getParams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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