Created
October 23, 2015 10:55
-
-
Save andreasvirkus/7e932c40ab72d42fdf91 to your computer and use it in GitHub Desktop.
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
/** | |
* Two snippets to query the GET variable from the URL | |
* | |
* @param variable | |
* @returns {*} value of the GET variable or false when it's missing | |
*/ | |
function queryGetVariable(variable) | |
{ | |
var query = window.location.search.substring(1); | |
var vars = query.split("&"); | |
for (var i=0;i<vars.length;i++) { | |
var pair = vars[i].split("="); | |
if(pair[0] == variable){return pair[1];} | |
} | |
return(false); | |
} | |
function queryGetVariable(variable) { | |
var value = location.search.match(new RegExp("[\?\&]" + variable + "=([^\&]*)(\&?)","i")); | |
return value ? value[1] : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment