waider: (Default)
waider ([personal profile] waider) wrote2004-04-15 12:58 pm
Entry tags:

stupid javascript tricks

Prompted inadvertently by ajd, a javascript currency conversion bookmark (works in Mozilla, no guarantees for anyone else): Convert Me, Baby! As it stands, it defaults to converting 1 unit of the source currency to USD.

Update: lj doesn't like it as it stands. here's what the URL looks like: javascript:frm=prompt('source currency');amt=prompt('amount');to=prompt('dest currency');if(!amt)amt=1;if(!to)to='USD';location.href='http://finance.yahoo.com/m5?a='+amt+'&s='+frm+'&t='+to

[identity profile] wisn.livejournal.com 2004-04-15 06:21 am (UTC)(link)
This is for XE, a minimalist-ish site:
javascript:frm=prompt('source%20currency');amt=prompt('amount');to=prompt('dest%20currency');if(!amt)amt=1;if(!to)to='USD';location.href='http://www.xe.com/ucc/convert.cgi?From='+frm+'&To='+to+'&Amount='+amt;

Quicksilver caches Safari bookmarks, so OS X users can request a currency conversion regardless of the foreground app. I like this.

I prefer oanda.com to Yahoo or XE - they'll not only provide currency conversion, but block value tables and calculate in trader fees - but their URL handling is too fussy for my weak javascript skillz.

[identity profile] wisn.livejournal.com 2004-04-15 06:24 am (UTC)(link)
One additional note for both these scripts: You identify the currency by three-letter identifier. United States = USD, Euro = EUR, S.Korean Won = KRW, and so on. The Yahoo and XE sites are not case sensitive.