it is very easy, you access the parameters through location.search
. split the queries, and decode components;
The code below is a self executing function, that processes the current window url as you need, and returns a scoped function that you can call.
let getParameterByName = function() {
let queries = location.search.substring(1).split('&'),
processed = {};
for (let query of queries) {
let [name, value] = query.split('=');
processed[decodeURIComponent(name)] = value? decodeURIComponent(value) : '';
}
return function(name) {
if (typeof processed[name] !== 'undefined')
return processed[name];
else
return null;
};
}();
Usage example:
var response_code = getParameterByName('response_code'),
response_description = getParameterByName('response_description');
Note that It will return null
if the query does not exist in the url.