Skip to content

Instantly share code, notes, and snippets.

@andrewlaskey
Last active September 11, 2015 23:15
Show Gist options
  • Save andrewlaskey/db1221a036ebf0b411c3 to your computer and use it in GitHub Desktop.
Save andrewlaskey/db1221a036ebf0b411c3 to your computer and use it in GitHub Desktop.
Turn query parameters from url in to object
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;
}
@andrewlaskey
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment