Is there a function somewhere which will take a string containing a URL and return an object with all the querystring key / value pairs? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I believe window.location.search.toQueryParams() is what you are looking for. Brandon On 8/11/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > > Is there a function somewhere which will take a string containing a URL and > return an object with all the querystring key / value pairs? > > Sam > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >
On 8/11/06, Sam wrote:> Is there a function somewhere which will take a string containing a URL and > return an object with all the querystring key / value pairs?In a recent-ish version of prototype, look at String.toQueryParams (prototype.js:195 in v1.5). Seth
There is one such function exactly:
String.toQueryParams()
var url = ''http://test.com/?this=test&perfect=true'';
var params = url.toQueryParams();
/*
params = {
this: ''test'',
perfect: ''true''
};
*/
Is that what you''re looking for?
-E
On 8/11/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>
wrote:>
>
> Is there a function somewhere which will take a string containing a URL and
> return an object with all the querystring key / value pairs?
>
> Sam
>
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
>
>
--
Eric Ryan Harrison, Developer
model13 Designs
> There is one such function exactly: > > String.toQueryParams() > > var url = ''http://test.com/?this=test&perfect=true''; > var params = url.toQueryParams(); >I don''t know how I missed this. I''m guessing I had "whole word" set in my editor search. Thanks, Sam
No problem. Seth mentioned in a followup post that it needed to be a ''recentish'' version of prototype, but I just checked 1.4 provided on http://prototype.conio.net and found it there as well. Anyone using anything less than 1.4 deserves the pain of that choice... ;) Just out of curiousity Sam, I notice that you are a frequent poster to this list. Are you writing anything specific or just having fun with javascript and prototype? Anything you can show off here? -E On 8/12/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > There is one such function exactly: > > > > String.toQueryParams() > > > > var url = ''http://test.com/?this=test&perfect=true''; > > var params = url.toQueryParams(); > > > > I don''t know how I missed this. I''m guessing I had "whole word" set in my > editor search. > > Thanks, > > Sam > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Eric Ryan Harrison, Developer model13 Designs
> Just out of curiousity Sam, I notice that you are a frequent poster to > this list. Are you writing anything specific or just having fun with > javascript and prototype? Anything you can show off here? >I''m working on an environment to host e-learning course content. Unfortunately I can''t send a sample URL I''m pleased with prototype.js cross-platform support, 3rd party extensions, and speed of development. Sam