Created
July 30, 2012 16:08
-
-
Save radius/3208063 to your computer and use it in GitHub Desktop.
Get URL Query String Parameters with Javascript
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 urlParams = (function () { | |
var _params={}, | |
e, | |
a = /\+/g, // Regex for replacing addition symbol with a space | |
r = /([^&=]+)=?([^&]*)/g, | |
d = function (s) { return decodeURIComponent(s.replace(a, " ")); }, | |
q = window.location.search.substring(1); | |
while (e = r.exec(q)) { | |
_params[d(e[1])] = d(e[2]); | |
} | |
return _params | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment