Thursday, June 22, 2006

JavaScript

I have decided that I want to write a snippet of something that I can envoke via a Firefox shortcut that will take a space delimited string and break it up and replace variables in the snippet with those values such that given the following as input in the address bar:

tr en fr

the output will be:

javascript:(function() {document.forms[1][1].value = "en|fr";})();

where the key word is "tr" and the location field in my shortcut was originally:

javascript:(function(){document.forms[1][1].value = "%s|%s";})();

One problem here, however, is the double %s isn't working as I hoped. %s1 doesn't work either, nor does %w. Which is odd, since I got %w's to work in a url replacement, but not in a JavaScript replacement.

Yes, I know I could make my life easier by passing the string "en|fr", but that won't work since this is only a small portion of my master plan.

I'm thinking I may have to use a regexp, but I want to avoid that for readability issues.

So, dear wonderful net-surfers, any brilliant suggestions? Let me know! Please!!

P.S. Sorry, Mumsy, these can't all make sense to you. That's just the way life goes.

0 Comments:

Post a Comment

<< Home