Skip to content

Instantly share code, notes, and snippets.

@lunaroja
Created May 2, 2013 05:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lunaroja/5500398 to your computer and use it in GitHub Desktop.
Save lunaroja/5500398 to your computer and use it in GitHub Desktop.
Simple jQuery plugin that gets URL parameter by name for either address or specific url.
jQuery.extend({
getParam: function(n,u) {
if(!u) var u = window.location.search;
var match = RegExp('[?&]' + n + '=([^&]*)').exec(u);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment