Last active
December 13, 2015 16:49
-
-
Save cookpete/4943243 to your computer and use it in GitHub Desktop.
Create a global object containing key/value pairs of URL parameters
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
function parseParams(string){ | |
var obj = {}; | |
string.replace(/[?&]?([^=]+)=([^&]*)/g, function(m,k,v) { obj[k] = v; }); | |
return obj; | |
} | |
var url = parseParams(location.search); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment