Convert Currencies with One Click

Yahoo! Finance can tell you how many euros there are in a U.S. dollar, and a little JavaScript can speed up the answer.

While browsing the Web, you might find yourself in some unusual places. You’re potentially just a click away from any site that exists, including online stores large and small, across the globe. The next time you’re reading about a bleeding-edge European cell phone from your home in the United States, you might want to find out just how much that £500 would be in U.S. dollars.

Yahoo! Finance’s Currency Converter (http://finance.yahoo.com/currency) can give you the answer. From this page, you can select a currency to convert from, a currency to convert to, and the amount of currency you’d like to convert.

This is a fairly painless process, but it still involves leaving your review site, opening a new browser window, and generally losing focus from all of those cutting-edge features of that smart phone you’re really interested in.

Because Yahoo!’s Currency Converter handles everything in the URL query string, you can write some JavaScript to automate this process and find out what you would need to pay, with just one click. For example, the following URL goes directly to the Yahoo! page that converts £500 into U.S. dollars:

http://finance.yahoo.com/currency/convert?amt=500&from=GBP&to=USD

The query string variables are fairly self-explanatory:

amt

The amount of currency to convert

from

The three-letter abbreviation for the currency you’re ...

Get Yahoo! Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.