Leer parámetros de la url con Javascript


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



Copy this code and paste it in your HTML
  1. function getUrlVars()
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.