Skip to content

Instantly share code, notes, and snippets.

@marciobarrios
Created November 21, 2009 04:00
Show Gist options
  • Save marciobarrios/239987 to your computer and use it in GitHub Desktop.
Save marciobarrios/239987 to your computer and use it in GitHub Desktop.
para transformar los parametros de una url en un objeto
/*
we have:
http://foo.com?nodeId=2&userId=3&sortOrder=name&sequence=asc
we want:
var params = {
nodeId : 2,
userId : 3,
sortOrder: name,
sequence: asc
}
*/
var url = location.search;
url = url.replace('?', '');
var queries = url.split('&');
var params = {};
for(var q in queries) {
var param = queries[q].split('=');
params[ param[0] ] = param[1];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment