Jake Paris


tagged with vanilla-js

GET Query Params with Javascript

Update April 2018 Sigh, the things we learn as we go… This is actually way easier than I made it before. In fact, it so easy it doesn’t really need these wrapper functions around…

Helper function (in vanilla js) to find a GET query parameter

var parseQueryParameters = function(){ var queryString = window.location.search; var queries = {}; if(queryString=='') return queries; var q = queryString.replace('?','').split('&'); q.forEach(function(pair){ var a = pair.split('='); if(typeof a[1]==='undefined') a.push(''); queries[a[0]] = a[1]; }); return queries;…