-1

I have a code but it is not running properly.

function QueryStringParam1(d) {
        var vars = [], hash;
        var q = document.URL.split('?')[0];   
        if (q != undefined) {
            q = q.split('&');
            for (var i = 0; i < q.length; i++) {
                hash = q[i].split('=');
                vars.push(hash[1]);
                vars[hash[0]] = hash[1];
            }
        }
        return vars[d];
    }
Ravi Verma
  • 182
  • 1
  • 3
  • 12

1 Answers1

2

Most likely you are trying to get query string value from this query. So you would be getting string having its value after '?' char.

So after split relevant string should be in 1 index not 0.. replace

var q = document.URL.split('?')[0]; 

by

var q = document.URL.split('?')[1];  
Arvind
  • 61
  • 3