jQuery: Get URL Parameters


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



Copy this code and paste it in your HTML
  1. $.extend({
  2. getUrlVars: function(){
  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. },
  13. getUrlVar: function(name){
  14. return $.getUrlVars()[name];
  15. }
  16. });

URL: http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.