jQuery urlParam - read URL parameters, query string


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.