Skip to content

Instantly share code, notes, and snippets.

@keeganbrown
Created June 12, 2013 15:09
Show Gist options
  • Save keeganbrown/5766142 to your computer and use it in GitHub Desktop.
Save keeganbrown/5766142 to your computer and use it in GitHub Desktop.
getQueryParamWithObj.js
// GET QUERY STRING VALUE FROM OBJ BY KEY
function getQueryParam (key, obj) {
if ( !obj || !obj.search ) var obj = location;
var a = obj.search.slice(1).split("&"), GET = [];
for (var i in a) { GET[a[i].split("=")[0]] = a[i].split("=")[1]; }
return GET[key] || null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment