Created
September 26, 2013 17:05
-
-
Save joshbeckman/6717179 to your computer and use it in GitHub Desktop.
Simple function to get all url query parameters for current page
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 params = {}; | |
if (location.search) { | |
var parts = location.search.substring(1).split('&'); | |
for (var i = 0; i < parts.length; i++) { | |
var nv = parts[i].split('='); | |
if (!nv[0]) continue; | |
params[nv[0]] = nv[1] || true; | |
} | |
} | |
// Now you can get the parameters you want like so: | |
var abc = params.abc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment