Skip to content

Instantly share code, notes, and snippets.

@michaelschofield
Created February 21, 2014 21:25
Show Gist options
  • Save michaelschofield/9143874 to your computer and use it in GitHub Desktop.
Save michaelschofield/9143874 to your computer and use it in GitHub Desktop.
Returns the address bar query string as a key/value object.
/*
* jquery.getQueryParameters.js
* Copyright (c) 2014 Nicholas Ortenzio
* The MIT License (MIT)
*
*/
jQuery.extend({
getQueryParameters : function(str) {
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment