Posted By

brandonjp on 07/07/10


Tagged

url js textmate jquery query parameters


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

brandonjp


jQuery urlParam - read URL parameters, query string


 / Published in: jQuery
 

  1. // thanks to Retrieve URL params with jQuery - jQuery - Snipplr Social Snippet Repository http://bit.ly/blNbaK
  2. // thanks to JQuery HowTo: Get URL parameters & values with jQuery http://bit.ly/b9rj6I
  3.  
  4. // parse the URL into query strings
  5. $.urlParam = function(name) {
  6. var results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href);
  7. if (!results) {
  8. return 0;
  9. }
  10. return results[1] || 0;
  11. }; // end urlParam setup

Report this snippet  

You need to login to post a comment.