Posted By

BjoernKW on 08/20/10


Tagged

url parameters


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

scilec


Get URL parameters with JavaScript


 / Published in: JavaScript
 

  1. function getUrlParameters()
  2. {
  3. var vars = [], hash;
  4. var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
  5. for(var i = 0; i < hashes.length; i++)
  6. {
  7. hash = hashes[i].split('=');
  8. vars.push(hash[0]);
  9. vars[hash[0]] = hash[1];
  10. }
  11. return vars;
  12. }

Report this snippet  

You need to login to post a comment.