Created
February 20, 2015 07:10
-
-
Save yorkie/e0e598cbb2154d7b5979 to your computer and use it in GitHub Desktop.
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 parseQuerystring (key) { | |
var href = location.href; | |
var start = href.indexOf('?'); | |
var obj = href.slice(start+1).split('&'); | |
var ret = {}; | |
obj.forEach(function (item) { | |
var vals = item.split('='); | |
var key = vals[0]; | |
var val = decodeURI(vals[1]).replace(/\+/g, ' '); | |
ret[key] = val; | |
}); | |
if (!key) | |
return ret; | |
else | |
return ret[key]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment