×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Gary Peach
Added: Jan 20, 2016 6:12 AM
Modified: Feb 5, 2016 4:55 PM
Views: 10
  1.         function getQueryParams(qs) {
  2.             qs = qs.split('+').join(' ');
  3.             var params = {},
  4.                     tokens,
  5.                     re = /[?&]?([^=]+)=([^&]*)/g;
  6.             while (tokens = re.exec(qs)) {
  7.                 params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
  8.             }
  9.             return params;
  10.         };
  11.        
  12.         var query = getQueryParams(document.location.search);
  13.         console.log(query);