Skip to content

Instantly share code, notes, and snippets.

@dangvanthanh
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save dangvanthanh/ed5ee3fa936a6f947bc9 to your computer and use it in GitHub Desktop.

Select an option

Save dangvanthanh/ed5ee3fa936a6f947bc9 to your computer and use it in GitHub Desktop.
Get URL Parameters Using JavaScript
/**
* Get URL Parameters Using JavaScript
*/
function getQueryParameters(qs) {
qs = qs.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
var regexPattern = '[\\?&]' + qs + '=([^&#]*)';
var regex = new RegExp(regexPattern);
var location = window.location.href;
var results = regex.exec(location);
return results == null ? null ? results[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment