grab GET vars in Javascript


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.