Skip to content

Instantly share code, notes, and snippets.

@pwightman
Created December 3, 2013 05:23
Show Gist options
  • Save pwightman/7764257 to your computer and use it in GitHub Desktop.
Save pwightman/7764257 to your computer and use it in GitHub Desktop.
// I swiped this from a stack overflow question somewhere, it works well.
window.getParameterByName = function(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Usage
if (getParameterByName("error")) {
// display error message
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment