Get the queryString module from: https://github.com/sindresorhus/query-string
-
-
Save bspavel/997e7177bdce4a890c0840db9ec02241 to your computer and use it in GitHub Desktop.
Get, set, modify url parameters in a query string with JavaScript.
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
// Get the queryString module from: | |
// https://github.com/sindresorhus/query-string | |
console.log(location.href); | |
// http://sindresorhus.com/?foo=bar | |
console.log(location.search); | |
// ?foo=bar | |
var parsed = queryString.parse(location.search); | |
console.log(parsed); | |
// {foo: 'bar'} | |
parsed.foo = 'unicorn'; | |
parsed.ilike = 'pizza'; | |
location.search = queryString.stringify(parsed); | |
console.log(location.search); | |
// ?foo=unicorn&ilike=pizza |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment