I want to get querystring value by javascript. I am using this function.
var qs = (function (a) {
if (a == "") return {};
var b = {};
for (var i = 0; i < a.length; ++i) {
var p = a[i].split('=');
if (p.length != 2) continue;
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
})(window.location.search.substr(1).split('&'));
It works well. But if there is no querystring value in the url, if is an error.
I want to modify it as if it find querysting value return it.
If there is no query string value then return word “Natural”
Can you help me please?
At the top you could write:
But that is really weird you would want to do this.