Skip to content

Instantly share code, notes, and snippets.

@robertsosinski
Created June 3, 2009 16:32
Show Gist options
  • Save robertsosinski/123078 to your computer and use it in GitHub Desktop.
Save robertsosinski/123078 to your computer and use it in GitHub Desktop.
Converts a query string to a Prototype.js Hash
Hash.fromQueryString = function(string) {
var hash = new Hash();
var array = string.gsub(/^#/, '').split(/=|&/);
for (var i = 0; i < array.length; i+=2) {
if(array[i +1] != undefined) {
hash.set(array[i], array[i + 1]);
}
}
return hash;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment