Javascript QueryString


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

default.aspx?id=5
queryString('id') will return 5
Also this will convert to lower case. IIS / ASP.net is not case sensitive so my function isn't either.


Copy this code and paste it in your HTML
  1. function queryString(ji)
  2. {
  3. ji = ji.toLowerCase();
  4. hu = window.location.search.substring(1).toLowerCase();
  5. gy = hu.split("&");
  6. for (i=0;i<gy.length;i++)
  7. {
  8. ft = gy[i].split("=");
  9. if (ft[0] == ji)
  10. return ft[1];
  11. }
  12. return "";
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.