Skip to content

Instantly share code, notes, and snippets.

@seyhunak
Created March 18, 2014 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seyhunak/9623017 to your computer and use it in GitHub Desktop.
Save seyhunak/9623017 to your computer and use it in GitHub Desktop.
Get url parameters with Javascript
function getURLParameters(url) {
var result = {};
var searchIndex = url.indexOf("?");
if (searchIndex == -1 ) return result;
var sPageURL = url.substring(searchIndex +1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
result[sParameterName[0]] = sParameterName[1];
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment