Bookmarklets

Web Browsers as Programmable Calculators

...for those special calculations

Almost any scientific formula can be turned into a bookmarklet. Scientific formulas tend to be small in size (like bookmarklets), and since bookmarklets can be easily configured within your Bookmarks/Favorites they enable you to quickly set up a range of special-purpose calculators for temporary or frequent calculations.

There are some advantages to using web browsers over traditional programmable calculators:
  • Ease of programming - JavaScript is a fairly easy scripting language to learn (see below), and has other applications.
  • Ease of distribution - If someone creates a bookmarklet which is a special-purpose calculator then they can distribute it through a webpage. The bookmarklet can be triggered while on the page or dragged into the Bookmarks/Favorites menu for permanent reuse.
  • Cross-platform - Calculators tend to use the part of JavaScript which is common to both major browsers. Unlike the languages used by most programmable calculators, bookmarklets can be shared between browsers.
  • Web browsers are free - most programmable calculators are expensive.
For those who like to make bookmarklets, there are a vast number of useful formulas that are good candidates: the lack of a fancy interface doesn't keep a useful formula from being useful, and formulas tend to be in the public domain (as any good scientist can tell you.)

To write a special-purpose calculator as a bookmarklet, study some of the examples in the Calculate/Convert section. You can get the "source" of a bookmarklet by copying the link location from the bookmarklet link, then paste it into a text editor and play with it.

For example, here is the source of a simple version of a Download Calculator which roughly tells how long it will take to download a file of known size using a 28.8 modem:

  javascript:
    X=prompt('File size:','');
    alert('At 28.8, the file will take about ' + X*1024*8/28800 + ' seconds to download.')


Try it.
Normally in a bookmarklet the script would all be on one line, but I've written this out on seperate lines for greater readability. The idea is quite simple: you just prompt for the input, then alert the output. Inside the alert you place a formula - in this case it's X*1024*8/28800, which converts between KiloBytes (which are used to describe file sizes) and Kilobits (used to describe transfer rates).

As you study more examples, you learn more tricks: ways of handling errors, taking more than one input variable, making it easier to copy the output, and so on. But the crucial part is in knowing a good formula to start with.

Once you've made a special-purpose calculator you can share it with others by making a link to it, just as you would with a webpage URL. Visitors to your page can keep the tool by pointing at the link and selecting "Add to Bookmarks/Favorites" from their (right-click) menu. (Macintosh/Unix users may have to rename the Bookmark after keeping it.) - Simple!

If you come up with any good ones, or need some extra help, please let me know!





Back