Skip to content

Instantly share code, notes, and snippets.

@mshirdel
Created June 13, 2017 12:57
Show Gist options
  • Save mshirdel/d7748578b81c132886aab7e01df7cf78 to your computer and use it in GitHub Desktop.
Save mshirdel/d7748578b81c132886aab7e01df7cf78 to your computer and use it in GitHub Desktop.
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment