Skip to content

Instantly share code, notes, and snippets.

View LukasGrebe's full-sized avatar

Lukas Grebe LukasGrebe

View GitHub Profile
@LukasGrebe
LukasGrebe / getQueryVariable.js
Last active February 17, 2016 09:34 — forked from reifman/Parse query string via javascript
Return the first value of a specified Querystring (location.search) field (variable). Handels '=','+' and URIComponent encoding
function getQueryVariable(variable) {
var query = window.location.search.replace("?", "");
for (var vars = query.split("&"), i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (decodeURIComponent(pair[0]).replace("+", " ") == variable) {
return decodeURIComponent(pair.slice(1).join("=")).replace("+", " ");
}
}
return void 0
}