Created
November 28, 2014 10:50
-
-
Save kkoziarski/be5a934ee3fe0c27497c to your computer and use it in GitHub Desktop.
Get query string by name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HELPERS (all kinds and types) | |
// Function for getting request query string params | |
// Source: http://stackoverflow.com/questions/901115/get-querystring-values-with-jquery | |
function getQueryStringByName(name) { | |
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | |
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); | |
var results = regex.exec(window.location.href); | |
if (results == null) | |
return null; | |
else | |
return decodeURIComponent(results[1].replace(/\+/g, " ")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment