Skip to content

Instantly share code, notes, and snippets.

@baras
Last active December 24, 2018 06:59
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 baras/ab0340add41388a14242abb3d787a996 to your computer and use it in GitHub Desktop.
Save baras/ab0340add41388a14242abb3d787a996 to your computer and use it in GitHub Desktop.
Get the URL query string parameters in JavaScript.
var queryString = {};
location.search.substr(1).split("&").forEach(function (pair) {
if (pair.length) {
var parts = pair.split("=");
queryString[parts[0]] = decodeURIComponent(parts[1].replace(/\+/g, " "));
}
});
console.log(queryString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment