Created
April 2, 2015 11:24
-
-
Save joshbeckman/540d09836498d32988f3 to your computer and use it in GitHub Desktop.
Assign client url params immediately on pageload
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
// grab url params and assign on page load | |
(function (window, document) { | |
var match, | |
pl = /\+/g, // Regex for replacing addition symbol with a space | |
search = /([^&=]+)=?([^&]*)/g, | |
decode = function (s) { | |
return decodeURIComponent(s.replace(pl, " ")); | |
}, | |
query = window.location.search.substring(1); | |
window._ourParams = {}; | |
while (match = search.exec(query)) | |
window._ourParams[decode(match[1])] = decode(match[2]); | |
})(this, this.document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment