Getting Query String Parameters from URL


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



Copy this code and paste it in your HTML
  1. function getQSP()
  2. {
  3. var qs = location.search.substring(1, location.search.length);
  4. var args = qs.split("&");
  5. var vals= [];
  6. for (var i=0; i < args.length; i++)
  7. {
  8. var nameVal = args[i].split("=");
  9. var temp = unescape(nameVal[1]).split('+');
  10. nameVal[1] = temp.join(' ');
  11. vals[nameVal[0]] = nameVal[1];
  12. }
  13. return vals;
  14. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.