Get Querystring Parameters Using JQuery

Prabhukiran345
Posted by Prabhukiran345 under jQuery category on | Points: 40 | Views : 695
If the URL contains a querystring with multiple parameters the following snippet will parse each parameter and store the array as a variable

var vars = [], hash;
var q = document.URL.split('?')[1];
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];
}
}

Comments or Responses

Login to post response