Last active
April 18, 2017 04:56
-
-
Save Blumed/208b6f654460639a5cd2ac502693eaff to your computer and use it in GitHub Desktop.
Create a query directory object out of a url.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript?page=1&tab=active#tab-top | |
let qd = {}; | |
if (location.href) { | |
let re = /(\#|\&)/; | |
location.href.substr(1).split(re).forEach(item => {let [k,v] = item.split("="); v = v && decodeURIComponent(v).replace(/\+/g, " "); (qd[k] = qd[k] || []).push(v)}) | |
} | |
//type qd into console to see all of the arrays created by script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment