Javascript String searchToJson()

Description

Javascript String searchToJson()



String.prototype.searchToJson = function () {
    var search = window.location.search.replace('?', "");
    var kvArr = search.split('&');
    var finalJson = {};
    for (i = 0; i < kvArr.length; i++) {
        var kvSplit = kvArr[i].split('=');
        finalJson[kvSplit[0].toLowerCase()] = decodeURI(kvSplit[1]);
    }// www .j  av a 2  s  . co m
    return finalJson;
}



PreviousNext

Related