Skip to content

Instantly share code, notes, and snippets.

@kparms
Created January 25, 2017 15:20
Show Gist options
  • Save kparms/054291450962c7071c6d12171d913867 to your computer and use it in GitHub Desktop.
Save kparms/054291450962c7071c6d12171d913867 to your computer and use it in GitHub Desktop.
Get Querystring values from URL using Javascript
/* KP: Read in querystring values and perform filtering */
var path = window.location.href;
$scope.searchTerms = path.indexOf('?') > 0 ? path.split('?')[1].split('&') : [];
if ($scope.searchTerms.length > 0) {
for (i = 0; i < $scope.searchTerms.length; i++) {
var searchTerm = $scope.searchTerms[i].split('=');
var name = searchTerm[0];
var value = searchTerm[1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment