Posted By

maceblue on 07/30/12


Tagged

get params


Versions (?)

get params in JS


 / Published in: JavaScript
 

get paramt

  1. // make GET-Params accessible in JS
  2. (function(){
  3. window.getparams = {};
  4. var s = window.location.search.substring(1).split('&');
  5. if(!s.length) return;
  6. for(var i = 0; i < s.length; i++) {
  7. var parts = s[i].split('=');
  8. window.getparams[unescape(parts[0])] = unescape(parts[1]);
  9. }
  10. }())
  11.  
  12. //use: window.getparams['id']

Report this snippet  

You need to login to post a comment.