Skip to content

Instantly share code, notes, and snippets.

@youngchief-btw
Last active July 8, 2020 19:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youngchief-btw/77935ebf80eb03118979bfb4af46e7f1 to your computer and use it in GitHub Desktop.
Save youngchief-btw/77935ebf80eb03118979bfb4af46e7f1 to your computer and use it in GitHub Desktop.
Get URL Parameters in JS
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(
m,
key,
value
) {
vars[key] = value;
});
return vars;
}
// getUrlVars()["x"];
@Jonyk56
Copy link

Jonyk56 commented May 1, 2020

UseFulVars = {...[1]}

@trentwiles
Copy link

trentwiles commented Jun 27, 2020

Not bad!

@youngchief-btw
Copy link
Author

Thanks! @RiversideRocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment