Posted By

chrisaiv on 04/27/10


Tagged

jquery


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

Ethyde
dhollifield
jeremyalfordgmailcom
ramirocalero
dubogii


jQuery: Get URL Parameters


 / Published in: jQuery
 

URL: http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.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. });

Report this snippet  

You need to login to post a comment.