Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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