Skip to content

Instantly share code, notes, and snippets.

@mike-zarandona
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-zarandona/5818e0c1087b4647c380 to your computer and use it in GitHub Desktop.
Save mike-zarandona/5818e0c1087b4647c380 to your computer and use it in GitHub Desktop.
Function to check for and return the values of URL parameters.
// Get URL parameters
function getURLParameter(name) {
name = name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)",
regex = new RegExp( regexS ),
results = regex.exec( window.location.href )
;
if( results === null ) {
return '';
}
else {
return results[1];
}
}
function getURLParameter(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b="[\\?&]"+a+"=([^&#]*)",c=new RegExp(b),d=c.exec(window.location.href);return null===d?"":d[1]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment