Posted By

relish on 07/19/11


Tagged

get


Versions (?)

grab GET vars in Javascript


 / Published in: JavaScript
 

  1. var $_GET = {};
  2. document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
  3. function decode(s) {
  4. return decodeURIComponent(s.split("+").join(" "));
  5. }
  6.  
  7. $_GET[decode(arguments[1])] = decode(arguments[2]);
  8. });

Report this snippet  

You need to login to post a comment.