The following tip allows you to quickly perform calculations via JavaScript in Firefox and Chrome. Many people use Google for this purpose, but this tip even works if your computer is offline.
javascript:alert(7*45)With the keywords feature [1] of Chrome and Firefox, you can abbreviate long URLs, including the one above. In this post, we will create a “calculator” keyword so that the previous calculation can be performed by typing just
js 7*45You can see that the keyword is invoked by typing the command js and the argument 7*45, separated by a space. You need to specify the following data to create a keyword:
http://www.google.com/#q=%sIf a keyword does not need an argument then you omit the %s.
javascript:7*45To create a keyword in Firefox, you do the following:
77 / 11 → 7 3.16 * 5 → 15.8 10 % 7 → 3
(255).toString(16) → 'ff' parseInt("ff", 16) → 255You need to put an integer in parenthesis to invoke a method on it. Otherwise the dot will be mistaken for a decimal point. Alternatively, you can type two dots or append .0.