Skip to content

Instantly share code, notes, and snippets.

@dggodfrey
Created March 13, 2014 19:09
Show Gist options
  • Save dggodfrey/9534821 to your computer and use it in GitHub Desktop.
Save dggodfrey/9534821 to your computer and use it in GitHub Desktop.
Returns the value of a url parameter
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment