Skip to content

Instantly share code, notes, and snippets.

@edm00se
Last active Mar 30, 2021
Embed
What would you like to do?
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