Skip to content

Instantly share code, notes, and snippets.

@Bizunow
Created August 31, 2017 11:48
Show Gist options
  • Save Bizunow/b9c25dec49e050b02b1135943311ab91 to your computer and use it in GitHub Desktop.
Save Bizunow/b9c25dec49e050b02b1135943311ab91 to your computer and use it in GitHub Desktop.
[JS get all url params] #js
function allUrlParams(url) {
var url = decodeURIComponent(url);
var paramsPart = url.split('?')[1];
if (!paramsPart)
return {};
var params = paramsPart.split('&');
var pairs = {};
for (var i = 0; i < params.length; i++) {
var param = params[i].split('=');
if (param.length == 2) {
pairs[param[0]] = param[1];
}
}
return pairs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment