1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  function getQueryString() {
    var result = {}, queryString = location.search.substring(1),
        re = /([^&=]+)=([^&]*)/g, m;

    while (m = re.exec(queryString)) {
      if (typeof result[decodeURIComponent(m[1])] == 'undefined'){
        result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
      } else {
        if (typeof result[decodeURIComponent(m[1])] == 'string'){
          result[decodeURIComponent(m[1])] = [result[decodeURIComponent(m[1])]];
        }
        result[decodeURIComponent(m[1])].push(decodeURIComponent(m[2]))
      }
    }

    return result;
  }