Skip to content

Instantly share code, notes, and snippets.

@ryanwinchester
Last active July 28, 2016 22:23
Show Gist options
  • Select an option

  • Save ryanwinchester/acf30edbd7a13d6e4d3dd42a7bee1ecd to your computer and use it in GitHub Desktop.

Select an option

Save ryanwinchester/acf30edbd7a13d6e4d3dd42a7bee1ecd to your computer and use it in GitHub Desktop.
Get query parameter from url
get_query_var(name) {
var pairs = window.location.search.substring(1).split("&");
return pairs.reduce((carry, pair) => {
if (pair.split("=")[0] == name)
return pair.substring(pair.indexOf("=") + 1);
return carry;
}, {});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment