Last active
February 14, 2018 20:30
-
-
Save dustinpoissant/bff22759c012057b2a834da0268ba62f to your computer and use it in GitHub Desktop.
JavaScript $_GET
This file contains 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
var $_GET = (function(){ | |
var params = {}; | |
if(location.href.indexOf("?") > -1){ | |
var string = location.href.split("?")[1]; | |
if(string.indexOf("#") > -1){ | |
string = string.split("#")[0]; | |
} | |
var kvp = string.split("&"); | |
for(var i=0; i<kvp.length; i++){ | |
var k = kvp[i].split("=")[0]; | |
if(k != ""){ | |
var v = kvp[i].split("=")[1]; | |
params[k] = v; | |
} | |
} | |
} | |
return params; | |
})(); |
This file contains 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
var $_GET=function(){var i={};if(location.href.indexOf("?")>-1){var r=location.href.split("?")[1];r.indexOf("#")>-1&&(r=r.split("#")[0]);for(var t=r.split("&"),a=0;a<t.length;a++){var f=t[a].split("=")[0];if(""!=f){var l=t[a].split("=")[1];i[f]=l}}}return i}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment