Wednesday, October 1, 2014

Get Query String from JavaScript

I use this javascript function in every other project and every time I have to go to the internet and search for it. I am just too lazy to look and copy it from the old projects. So I am copying it from the internet to save it in my personal source code repository.
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

var strValue = getParameterByName('Value');

document.write(strValue);

Knowledge Chat Bot (No Code)

Recently my customers was looking for a solution where on-field guys can search for answers related to their tasks and it was a perfect scen...