Skip to content

Instantly share code, notes, and snippets.

@joshbeckman
Created April 2, 2015 11:24
Show Gist options
  • Save joshbeckman/540d09836498d32988f3 to your computer and use it in GitHub Desktop.
Save joshbeckman/540d09836498d32988f3 to your computer and use it in GitHub Desktop.
Assign client url params immediately on pageload
// 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