Skip to content

Instantly share code, notes, and snippets.

@mkokes
Last active December 31, 2015 20:09
Show Gist options
  • Select an option

  • Save mkokes/cfd6626555c899dbb55a to your computer and use it in GitHub Desktop.

Select an option

Save mkokes/cfd6626555c899dbb55a to your computer and use it in GitHub Desktop.
Get the URL parameters from a URL using jQuery
//Parse parameters in URL
function getURLParameter(sParam)
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
//Usage Examples
var tech = getURLParameter('technology');
var blog = getURLParameter('blog');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment