Created
August 31, 2017 11:48
-
-
Save Bizunow/b9c25dec49e050b02b1135943311ab91 to your computer and use it in GitHub Desktop.
[JS get all url params] #js
This file contains hidden or 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
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