Last active
September 11, 2015 23:15
-
-
Save andrewlaskey/db1221a036ebf0b411c3 to your computer and use it in GitHub Desktop.
Turn query parameters from url in to object
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 getQueryObj() { | |
var queryObj = {}; | |
if (window.location.search.indexOf('?') > -1) { | |
var query = window.location.search.split(/\?/), | |
params = query[1].split("&"), | |
for (var i = 0; i < params.length; i++) { | |
var keyVal = params[i].split("="); | |
queryObj[keyVal[0]] = keyVal[1]; | |
} | |
} | |
return queryObj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussion here https://css-tricks.com/snippets/javascript/get-url-variables/