Get QueryString value using JavaScript

As you all know that in C# we can easily fetch query string values using Request.QueryString collection. But you may ask how can we fetch values in JavaScript so here is the code snippet to achieve this.


function getQueryStringValue(param) {
        qryString = window.location.search.substring(1);
        qryParmas = qryString.split("&");
        for (i = 0; i < qryParmas.length; i++) {
            params = qryParmas[i].split("=");
            if (params[0] == param) {
                return params[1];
            }
        }
        return null;
    }

Comments

Popular posts from this blog

Switch from Classic to Claims Authentication in SharePoint 2010

How to query list data using web service