Skip to content

Instantly share code, notes, and snippets.

@edm00se
Last active March 30, 2021 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edm00se/abae980afeda1b2086d9581b36e24f99 to your computer and use it in GitHub Desktop.
Save edm00se/abae980afeda1b2086d9581b36e24f99 to your computer and use it in GitHub Desktop.
for the "signs of an advancing web" blog post https://edm00se.io/web/sings-of-the-web-advancing
const parm = new URLSearchParams(window.location.search);
console.log(parm.get('foo')); // 'bar'
function getQueryParam(searchKey){
var qs = window.location.split('?')[1];
var parmAr = qs.split('&');
var parm = {};
for(i = 0; i<parmAr.length; i++) {
var cur = parmAr[i].split('=');
var key = cur[0];
var val = cur[1];
parm[key] = val;
}
return parm[searchKey];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment