Javascript and GET Variables

Penned on .

Ever needed to deeplink an ajax application or prepopulate some form variables from a GET string on the client-side?  Well, here's a little javascript snippet that will help accomplish just that:

function splitURLVars() {   var getData = new Array();
    var vars =;
    if (vars) {
      vars = vars.substr(1);
      var pairs = vars.split("&");
      for (var i = 0; i < pairs.length; i++) {
        var formData = pairs[i].split("=");
        var name = formData[0];
        var value = formData[1];
        getData[name] = value;
  return getData;