Posted By

geekyjohn on 01/18/10


Tagged

get url javascript jquery request parameters


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

simmu
alejandrosuch
jfherring
brandonjp
derekholmes
czachor
scilec


Get URL Parameters with jQuery | Improved


 / Published in: jQuery
 

This is an improvement on http://snipplr.com/view/11583/retrieve-url-params-with-jquery/ I found IE wasn't liking the results[1] when no param was set. This fixes that issue.

  1. $.urlParam = function(name){
  2. var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
  3. if (!results) { return 0; }
  4. return results[1] || 0;
  5. }

Report this snippet  

You need to login to post a comment.