Created
July 30, 2009 10:44
-
-
Save riklomas/158649 to your computer and use it in GitHub Desktop.
Query string in JS
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
var querystring = function () { | |
var obj = {}; | |
var query = window.location.search.substring(1); | |
if (query != "") { | |
var vars = query.split("&"); | |
for (var i = 0; i < vars.length; i++) { | |
var p = vars[i].split("="); | |
obj[p[0]] = p[1]; | |
} | |
} | |
return obj; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment