Skip to content

Instantly share code, notes, and snippets.

@niczak
Created April 1, 2013 16:50
Show Gist options
  • Select an option

  • Save niczak/5286125 to your computer and use it in GitHub Desktop.

Select an option

Save niczak/5286125 to your computer and use it in GitHub Desktop.
URL Parser
function getParameterByName(param)
{
param = param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + param + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
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