Skip to content

Instantly share code, notes, and snippets.

Created November 28, 2014 10:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kkoziarski/be5a934ee3fe0c27497c to your computer and use it in GitHub Desktop.
Get query string by name
// HELPERS (all kinds and types)
// Function for getting request query string params
// Source:
function getQueryStringByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(window.location.href);
if (results == null)
return null;
return decodeURIComponent(results[1].replace(/\+/g, " "));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment